AJAX AutoCompleteExtender 问题,急!!!
执行时总是提示“JavaScript 运行时错误: 无法获取未定义或 null 引用的属性“UI”,请各位帮忙,谢谢!
出错位置:
Sys.Application.add_init(function() {
$create(Sys.Extended.UI.AutoCompleteBehavior, {"delimiterCharacters":"","firstRowSelected":true,"id":"MainContent_AutoCompleteExtender1","minimumPrefixLength":1,"serviceMethod":"GetData","servicePath":"autoCompExtenderServer.asmx"}, null, null, $get("MainContent_txtBox1"))
网页:
<%@ Page Title="主页" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
#Text1
{
margin-bottom: 0px;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
<asp:TextBox ID="txtBox1" runat="server"></asp:TextBox>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</p>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtBox1"
ServicePath="autoCompExtenderServer.asmx"
ServiceMethod="GetData"
CompletionSetCount="10"
FirstRowSelected="true"
MinimumPrefixLength="1">
</asp:AutoCompleteExtender>
</asp:Content>
WebService:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
namespace WebApplication3
{
/// <summary>
/// autoCompExtenderServer 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class autoCompExtenderServer : System.Web.Services.WebService
{
[WebMethod]
public string[] GetData(string prefixText, int count)
{
string[] data = new string[10000];
for (int i = 0; i < data.Length; i++)
data[i] = i.ToString("0000");
return data.Where(p => p.IndexOf(prefixText) >= 0).Take(count).ToArray();
}
}
}