如何在JQuery中从转发器中查找控件ID [英] how to find control id from a repeater in JQuery

查看:83
本文介绍了如何在JQuery中从转发器中查找控件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,



i有asp.net网站,我正在使用JQuery自动完成文本框。



成功为自动完成文本框做了,但是当我把它放在转发器中时,

然后jquery无法找到文本框的id。



我的JQuery代码:

< script type =text / javascript> 
$(document).ready(function(){
$(#<%= txtSearch.ClientID%>)。autocomplete({//查找文本框ID
source:函数(请求,响应){
$ .ajax({
url:'<%= ResolveUrl(〜/ Service.asmx / GetCustomers)%>',
数据: {'prefix':'+ request.term +'},
dataType:json,
类型:POST,
contentType:application / json; charset = utf-8,
成功:函数(数据){
响应($。map(data.d,function(item){
return {
label:item。 split(' - ')[0],
val:item.split(' - ')[1]
}
}))
},
错误:function(response){
警报(response.responseText);
},
失败:函数(响应){
alert(response.responseText);
}
});
},
select:function(e,i){
$(#<%= hfCustomerId.ClientID%>)。val(i.item.val); / / hidden field id
},
minLength:1
});

});
< / script>





HMTL代码

< asp:UpdatePanel ID =UpdatePanel1 runat =server> 
< ContentTemplate>
< div class =CSSTableGenerator>
< asp:Repeater ID =Repeater1runat =server>
< HeaderTemplate>
< table style =width:100%;>
< tr>
< td style =width:100px;> ;
价格参考#
< / td>
< td style =width:100px;>
Out Ref#
< / td>
< td style =width:200px;>
说明
< / td>
< td style =width:100px;>
数量
< / td>
< td style =width:100px;>
单位
< / td>
< td style =width:100px;>
单价
< / td>
< td style =width:110px;>
USD
< / td>
< / tr>
< / HeaderTemplate>
< ItemTemplate>
< tr>
< td>
< asp:TextBox ID =txtSearchWidth =100pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox3Width =100pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox4Width =200pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox5Width =100pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox6Width =100pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox7Width =100pxrunat =server>< / asp:TextBox>
< / td>
< td>
< asp:TextBox ID =TextBox8Width =100pxrunat =server>< / asp:TextBox>
< / td>
< / tr>
< / ItemTemplate>
< FooterTemplate>
< / table>
< / FooterTemplate>
< / asp:Repeater>
< / div>
< / ContentTemplate>
<触发器>
< asp:AsyncPostBackTrigger ControlID =txtrows/>
< /触发器>
< / asp:UpdatePanel>







任何人都可以帮助我,如何找到控制的id,那个是,来自JQuery转发器的
文本框ID。



我创建了一个Web用户控件并放置了JQuery代码&我在Web用户控件中设置了一个文本框,这个userControl已放入转发器。



有时它会调用该事件但不是所有时间,为什么,我没有得到那个。



当我把这个userControl放在那个转发器之外然后它工作正常。



但不在转发器中。



请帮帮我们。



我昨天被困住了,努力,我落后于我的日程安排。请帮帮我。







Rended HMTL

转发器代码未显示在视图中***:O 



please,



谢谢

解决方案

(document).ready(function(){


(#<%= txtSearch。 ClientID%>)。autocomplete({//查找文本框ID
来源:函数(请求,响应){


.ajax({
url:' <%= ResolveUrl(〜/ Service.asmx / GetCustomers)%>',
data:{'prefix':'+ request.term +'},
dataType :json,
类型:POST,
contentType:application / json; charset = utf-8,
成功:函数(数据){
response(

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

解决方案

(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(


这篇关于如何在JQuery中从转发器中查找控件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆