aspx文件-------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DeliverGoods.aspx.cs" Inherits="produce_DeliverGoods" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xml:lang>
<head runat="server">
<title>仓库发货</title>
</head>
<body class="frameborder">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" TargetControlID="TextBox1" CompletionSetCount="12"
ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" CompletionInterval="1000" EnableCaching="true" MinimumPrefixLength="2" runat="server">
</cc1:AutoCompleteExtender> </div>
<asp:TextBox ID="TextBox1" runat="server" Width="285px" />
</form>
</body>
</html>
AutoComplete.cs文件----------------------------------------------------------------------------------
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
/// <summary>
/// AutoComplete 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class AutoComplete : System.Web.Services.WebService
{ [WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
string[] aa ={ "ttttttt", "ttttt333", "tttttcccc", "tttaasawsees", "tt77567567" };
return aa;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DeliverGoods.aspx.cs" Inherits="produce_DeliverGoods" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xml:lang>
<head runat="server">
<title>仓库发货</title>
</head>
<body class="frameborder">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" TargetControlID="TextBox1" CompletionSetCount="12"
ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" CompletionInterval="1000" EnableCaching="true" MinimumPrefixLength="2" runat="server">
</cc1:AutoCompleteExtender> </div>
<asp:TextBox ID="TextBox1" runat="server" Width="285px" />
</form>
</body>
</html>
AutoComplete.cs文件----------------------------------------------------------------------------------
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
/// <summary>
/// AutoComplete 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class AutoComplete : System.Web.Services.WebService
{ [WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
string[] aa ={ "ttttttt", "ttttt333", "tttttcccc", "tttaasawsees", "tt77567567" };
return aa;
}
}
嘿嘿!
在web.config里面加这个
<system.web><httpHandlers>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<httpHandlers>
</system.web>