Click here to Skip to main content
16,020,261 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

i have asp.net website where i'm using JQuery for autocomplete textbox.

successfully i did for autocomplete textbox, but when i'm placing it in a repeater,
then the jquery is not able to find the id of textbox.

my JQuery Code:
<script type="text/javascript">
    $(document).ready(function () {
        $("#<%=txtSearch.ClientID %>").autocomplete({ //finding textbox id
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/Service.asmx/GetCustomers") %>',
                    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) {
                $("#<%=hfCustomerId.ClientID %>").val(i.item.val);// hidden field id
            },
            minLength: 1
        });

    }); 
</script> 


HMTL Code"
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="CSSTableGenerator">
            <asp:Repeater ID="Repeater1" runat="server" >
                <HeaderTemplate>
                    <table style="width: 100%;">
                        <tr>
                            <td style="width: 100px;">
                                Price Ref#
                            </td>
                            <td style="width: 100px;">
                                Out Ref#
                            </td>
                            <td style="width: 200px;">
                                Description
                            </td>
                            <td style="width: 100px;">
                                Quantity
                            </td>
                            <td style="width: 100px;">
                                Unit
                            </td>
                            <td style="width: 100px;">
                                Unit Price
                            </td>
                            <td style="width: 110px;">
                                USD
                            </td>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:TextBox ID="txtSearch" Width="100px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox3" Width="100px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox4" Width="200px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox5" Width="100px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox6" Width="100px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox7" Width="100px" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="TextBox8" Width="100px" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="txtrows" />
    </Triggers>
</asp:UpdatePanel>



can any one please help me, how to find the controld id, that is,
textbox id from a repeater in JQuery.

I have create one web user control and placed JQuery code & a textbox in the web user control and this userControl i have placed in the repeater.

some time it is calling the event but not all the time, why, i didn't get that.

when i placed this userControl outside that repeater then it is working good.

but not in the repeater.

Please help me guys.

i'm stuck from yesterday, trying hard, i'm behind my schedule. please help me.



Rended HMTL
the repeater code is not displaying in the view souces *** :O

please,

Thanks
Posted
Updated 12-Oct-14 3:57am
v9
Comments
Afzaal Ahmad Zeeshan 11-Oct-14 14:31pm    
You want to get which ID? In the part where you're having a comment, there you're talking about? Can you show the HTML part, from where to get the ID?
Nelek 12-Oct-14 5:16am    
Please read: best way to post code snippets[^]

You don't need to post the full code, only the ones failing. Try to debug and isolate the areas that work together and trigger the error
abdul subhan mohammed 12-Oct-14 9:36am    
the repeater code is not displaying in the view souces

1 solution

Instead of
$("#<%=txtSearch.ClientID %>").autocomplete({ //finding textbox id

Have the below...
$("input [id*=txtSearch]").autocomplete({ //finding textbox id
 
Share this answer
 
Comments
abdul subhan mohammed 12-Oct-14 2:58am    
sorry, dude,i have tried your sol'n but still its not working... any other sol'n...
This is a nice solution actually. I have implemented many times without any issues. I suggest you to debug and see if it is going inside the event or not. Also check the developer tool console tab.

Else do one thing. Just give me the rendered HTML of the repeater by getting it from the browser source. I will try at my end and give you the demo.
abdul subhan mohammed 12-Oct-14 4:11am    
plz check i have added html code
This is the aspx. I am asking the HTML which is rendered in browser, when you browse it from browser. You can get by "View Source".
abdul subhan mohammed 12-Oct-14 5:17am    
now i haved added rended HTML code plz check

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900