【发布时间】:2015-08-31 13:27:32
【问题描述】:
我想通过在更新面板中的转发器“repAbc”中对文本框控件“txtAbc”使用带有 Web 服务的 jquery 来执行自动完成。自动完成功能仅在更新面板回发之前起作用。回发后,它无法正常工作。
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="repAbc" runat="server" OnItemCommand="repAbc_ItemCommand"
OnItemDataBound="repAbc_ItemDataBound">
<ItemTemplate>
<asp:TextBox ID="txtAbc" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
$(function () {
$("[id$=txtAbc]").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Services.asmx/GetAbcMethod") %>',
data: "{ 'prefix': '" + escape(request.term) + "', 'varType':'eqType'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
value: item
}
}));
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
minLength: 1
}); });
</script>
【问题讨论】:
-
您在标记中的文本框 ID 是
txtAbc,您的 jquery 选择器是id$=txtEqType这是一个错字还是您的真实代码? -
txtAbc 还是 txtEqType?
-
您是否在控制台中遇到任何错误,我认为您应该将选择器更改为 $( "input[id$=txtEqType]" ) 之类的东西。正如@neel 所说,我想它应该是 txtabc 代替 txtEqType
-
我想为我的错字道歉。我所有的代码都运行良好,没有发生错误我怀疑它在我的转发器中找不到我的控制。有什么帮助吗?谢谢。
-
尝试在
中添加 clientidmode="Static"
标签: javascript c# jquery ajax web-services