AJAX AutoCompleteExtender 问题,急!!!

qsfsea qsfsea 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
执行时总是提示“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();
}
}
}

...全文
评论 2
收藏 已收藏
分享
返回顶部
qsfsea
.NET社区 62,272 成员 668,968 内容