Try Now
More in this section

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

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

2 posts, 0 answered
  1. Bohdan
    Bohdan avatar
    1 posts
    18 Jul 2012
    18 Jul 2012
    Link to this post
    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.
  2. Brett Whittington
    Brett Whittington avatar
    89 posts
    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. 
2 posts, 0 answered