我正在使用ajax自动完成扩展器,但它在这里不起作用是代码 [英] i am using ajax autocomplete extenter but it not work here is the code
本文介绍了我正在使用ajax自动完成扩展器,但它在这里不起作用是代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" TargetControlID="auto" MinimumPrefixLength="1" EnableCaching="false" ServicePath="WebService.asmx" BehaviorID="auto" ServiceMethod="HelloWorld" runat="server">
</cc1:AutoCompleteExtender>
<asp:TextBox ID="auto" style="position:absolute; left: 285px; top: 71px;" runat="server" Width="207px" ></asp:TextBox>
Web服务代码为
webservice code is
[WebMethod]
public string[] HelloWorld(String wscoded)
{
String server = "server=192.168.20.250;UID=acetrip;pwd=cucumber27;database=myvacations";
String que = "SELECT DISTINCT WSCode, DestName, Country FROM tblHotelDestination WHERE (WSCode like '" + wscoded + "%')";
DataSet ds = new DataSet();
SqlDataAdapter ada = new SqlDataAdapter(que,server );
ada.Fill(ds);
int i=0;
String[] dest = new string[ds.Tables[0].Rows.Count];
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows )
{
dest.SetValue(dr[0].ToString(), i);
i++;
}
}
return dest;
}
推荐答案
将ScriptMethod属性添加到您的方法中,并将签名更新为以下内容:
Add the ScriptMethod attribute to your method and update the signature to the following:
public string[] HelloWorld(string prefixText, int count)
...并确保大小写匹配.适当地更新您的代码(新的变量名).这是文档所需的签名.
我认为其他一切都很好.
干杯,
-詹姆斯
...and make sure the case matches. Update your code appropriately as well (new variable name). This is the signature required by the docs.
I think everything else looks okay.
Cheers,
-James
这篇关于我正在使用ajax自动完成扩展器,但它在这里不起作用是代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文