Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
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" this is dynamic generated id through this id not find the textbox value
Posted
Updated 10-Jul-12 0:51am
v2
Comments
Shemeer NS 10-Jul-12 7:48am    
What excatly you are looking for...please give more details to get the right answer...
Member 11097136 7-Oct-14 8:51am    
In my page i have to add rows dynamically and remove rows dynamically. I have one checkbox and one text boxe for each row which is added dynamically.

Adding and deleting rows works fine. I have problem after deleting. This is due to unchange of id value for checkbox and textboxes.

I assigned the id value in array and incremented while adding and decremented while removing. But the the id and values of the textboxes is not exact. How to fix this?

'ctl00_TextBoxCol_0' this is clientID you can handle control through clientId in javascript.

Instead use
TextBox txtBox = (TextBox)Page.FindControl("TextBoxCol_0");
 
Share this answer
 
Comments
2011999 10-Jul-12 7:18am    
how to write get id for javascript
pradiprenushe 10-Jul-12 8:03am    
Why you want clientID? You want to find textbox in javascript or in code behind?
2011999 10-Jul-12 8:19am    
based on clent id data store in database (Enter text in textboxes)
Hi,

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

And for finding any asp.net control through javascript use

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


Hope this will help you,

Thanks
-Amit.
 
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