Control 'Designer'. Have problems with getting ID of

Posted by Community Admin on 04-Aug-2018 14:30

Control 'Designer'. Have problems with getting ID of new added element * in repeater

All Replies

Posted by Community Admin on 18-Jul-2012 00:00

Main idea is:
Button Clicks -> Add's TextBoxes ->From some place writing smth in them .
How we can get Id of that textboxes.?
May-be you have some code samples or howto.

Posted by Community Admin on 20-Jul-2012 00:00

First of all, this is a general .NET question so you can also find lots of examples of this on other sites.  Secondly, you are not giving us enough detail on what your are trying to do. Are you trying to get the ID on the client or on the server?  I am going to try and guess.

It sounds like you are dynamically adding a new control to your page, can the user add more than one of these controls?  This important because .NET will not let you have any server side controls that have the exact same ID.  Secondly, if you are not declaring the new element's ClientIDMode as static, .NET is going to automatically assign a dynamic ID which is usually really long and could possiblly change on you so it will be hard to determine what it is. 

When I've had this problem in the past when creating this dynamic content, I set the ClientIDMode to static and give it an IDName something like "myID" + 1.  So that I know the ID's of all my controls based on the number.  With that you should be able to find the last added control because the ID will have the largest number. 

This thread is closed