0
我想通過使用帶web服務的jquery在updatepanel內的中繼器「repAbc」中的文本框控件「txtAbc」執行自動完成。自動完成功能僅在updatepanel回發之前起作用。回發之後,它不起作用。如何通過使用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'這是一個錯字還是這是您的真實代碼? – Michael
txtAbc或txtEqType? – Neel
你在控制檯中是否有任何錯誤,我認爲你應該改變你的選擇器到$(「input [id $ = txtEqType]」)。作爲@neel說我想它應該txtabc inplace of txtEqType – Devjosh