Click here to Skip to main content
15,884,917 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Comments
senguptaamlan 23-Aug-12 9:30am    
can you describe what you want to do by getting the textbox id using javascript...it will help us to give much more accurate solution approach for Ur solution.

You need to get the textbox by its ClientID.
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[^]
 
Share this answer
 
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
 
Share this answer
 
use RowCommand event for the grid view.
 
Share this answer
 

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