如何在动态ID中查找文本框值 [英] How find textbox value in throgh dynamic id

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

问题描述

TextBox tb = new TextBox();
                    //tb.ID = "TextBoxCol_" + i + "Col_" + j;
                    tb.ID = "TextBoxCol_" + i;
                    cell.Controls.Add(tb);
                    row.Cells.Add(cell);
TextBox txtBox = (TextBox)Page.FindControl("ctl00_TextBoxCol_0");


"ctl00_TextBoxCol_0"是通过此ID动态生成的ID,找不到该文本框值.


"ctl00_TextBoxCol_0" this is dynamic generated id through this id not find the textbox value

推荐答案

''ctl00_TextBoxCol_0''这是clientID,您可以通过clientId处理javascript.

而是使用
''ctl00_TextBoxCol_0'' this is clientID you can handle control through clientId in javascript.

Instead use
TextBox txtBox = (TextBox)Page.FindControl("TextBoxCol_0");




即使您可以修复您的ClientID.检查此链接 [ ^ ]

对于通过javascript查找任何asp.net控件,请使用

Hi,

Even you can fix your ClientID. Check this link[^]

And for finding any asp.net control through javascript use

var txtdate1 = document.getElementById('<%=txtdate1.ClientID%>');



希望这对您有帮助,

谢谢
-Amit.



Hope this will help you,

Thanks
-Amit.


这篇关于如何在动态ID中查找文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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