10 Aug 2012
20 Jul 2012
Link to this post
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.