网格内的访问文本框ID
问题描述:
大家好,
我在网格内有一个文本框,而该网格在usercontrol内.在这种情况下,如何访问Javascript
Hi all,
I have a textbox inside the grid and that grid is inside the usercontrol. in that case how can i access the textbox id in Javascript
答
中的文本框ID,您需要通过其ClientID
获取文本框.
浏览以下链接以完成任务.
如何在JQuery中访问ASP.NET控件客户端ID [访问其他TD中控件的ClientID [ ^ ]
从JQuery访问文本框 [
You need to get the textbox by itsClientID
.
Go through the below links to do your task.
How to Access ASP.NET Controls client id in JQuery[^].
Accessing ClientID of a Control in a different TD[^]
Access Textbox from JQuery[^]
文本框是服务器控件,您无法访问它直接带有文本框ID.
原因是处理后发送给用户的任何Web控件都是html,如果您看到源,则ID会更改.
试试这个
The Textbox is a server control and you cannot access it directly with the text box id.
The reason is any web control when processed and send back to user is a html and if you see the source, the id is changed.
Try this
var obj = document.getElementById("<%= textbox1.ClientID %>)
alert(obj.value);
希望这会有所帮助.
欢呼
Hope this helps.
cheers
对网格视图使用RowCommand事件.
use RowCommand event for the grid view.