Hi,
I am trying to use j-query autocomplete but i am getting this error: "The name 'txt_UID' does not exist in the current context" I am using the same code that Mudassar Khan posted on his website but the example i was following uses a text-box that was outside of the gridview. But my textbox is inside the gridview. How can i make the autocomplete to work a text-box that is inside gridview? please please help. thank you so much. here is my code:
-- here is my javascript
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txt_UID.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/Service.asmx/GetUserNames") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("#<%=hfUserId.ClientID %>").val(i.item.val);
},
minLength: 1
});
});
</script>
-- and here is my gridview:
<asp:GridView ID="GridView1" runat="server" Width="870px"
AutoGenerateColumns="False" Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B"
HeaderStyle-BackColor="green" ShowFooter="True"
CellPadding="4" BackColor="White" BorderColor="#336666"
BorderStyle="Double" BorderWidth="3px"
DataKeyNames="TSK_ID">
<AlternatingRowStyle BackColor="#C2D69B" />
<Columns>
<asp:TemplateField ItemStyle-Width="150px" HeaderText="User Name">
<ItemTemplate>
<asp:TextBox ID="txt_UID" runat="server" Text='<%# Eval("UID")%>'
Width="230px" BackColor="LightGoldenrodYellow"></asp:TextBox>
</ItemTemplate>
<ItemStyle Width="150px" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="false" >
<ItemStyle Font-Size="Smaller" ForeColor="#FF3300" />
</asp:CommandField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
</asp:GridView>