• 主页
  • ASP
  • .NET Framework
  • Web Services
  • VB
  • VC
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • LINQ
qsfsea 2014年05月09日
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();
}
}
}

...全文
72 点赞 收藏 2
写回复
2 条回复

还没有回复,快来抢沙发~

发动态
发帖子
.NET技术社区
创建于2007-09-28

4.8w+

社区成员

66.8w+

社区内容

.NET技术交流专区
社区公告
暂无公告