AjaxControlToolKit.AutoCompleteExtender 自动下拉
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div> 下拉框<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" MinimumPrefixLength="2"
CompletionSetCount="8" TargetControlID = "TextBox1" ServicePath="http://localhost:8180/WebServiceProject/Service.asmx"
ServiceMethod="HelloWorld" runat="server">
</cc1:AutoCompleteExtender>
</div>
注意 , 要先运行你的service.
using System.Web.Script.Services;//关键程序集引用
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[ScriptService()]//一定要添
[System.Web.Script.Services.ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string[] HelloWorld()
{
string[] a = new string[] { "1", "2", "3", "4" };
return a;
}
}
浙公网安备 33010602011771号