ID of dynamically inserted user control

Discussion in 'ASP .Net' started by Bijoy Naick, Nov 17, 2004.

  1. Bijoy Naick

    Bijoy Naick Guest

    I am inserting controls dynamically into my page; both Web Controls and User
    Controls. Code Below..

    I noticed that inspite of specifying the ID for the user controls, in the
    HTML, the name is set to : myUC2:_ctl0.. Whats with the :_ctl0?? How can I
    get rid of it?

    Bijoy

    -----------------

    Dim newControl As Control

    for count = 1 to 5
    newControl = New Textbox()
    newControl.ID = "myTextBox" & count
    Page.Controls.Add(newControl)
    next

    For User Controls I do

    Dim uc As UserControl

    for count = 1 to 5
    uc = LoadControl("file.ascx")
    uc.ID = "myUC" & count
    Page.Controls.Add(uc)
    next
    Bijoy Naick, Nov 17, 2004
    #1
    1. Advertising

  2. Bijoy Naick

    Kikoz Guest

    You can't unless you give every inserted control its ID yourself. If your ID
    is "MyID" it look like this: <containerID>:MyID.
    And why would you need to get rid of it?


    "Bijoy Naick" <> wrote in message
    news:...
    >I am inserting controls dynamically into my page; both Web Controls and
    >User
    > Controls. Code Below..
    >
    > I noticed that inspite of specifying the ID for the user controls, in the
    > HTML, the name is set to : myUC2:_ctl0.. Whats with the :_ctl0?? How can I
    > get rid of it?
    >
    > Bijoy
    >
    > -----------------
    >
    > Dim newControl As Control
    >
    > for count = 1 to 5
    > newControl = New Textbox()
    > newControl.ID = "myTextBox" & count
    > Page.Controls.Add(newControl)
    > next
    >
    > For User Controls I do
    >
    > Dim uc As UserControl
    >
    > for count = 1 to 5
    > uc = LoadControl("file.ascx")
    > uc.ID = "myUC" & count
    > Page.Controls.Add(uc)
    > next
    >
    >
    >
    Kikoz, Nov 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lucky
    Replies:
    0
    Views:
    500
    lucky
    Jan 12, 2005
  2. Replies:
    1
    Views:
    539
    Andrew Thompson
    Nov 19, 2007
  3. John Burke

    Determining 'first load' state of a dynamically inserted control

    John Burke, May 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    231
    Victor Garcia Aprea [MVP]
    May 5, 2004
  4. gauty
    Replies:
    1
    Views:
    857
    Kashish Malhotra
    Apr 29, 2010
  5. Alvaro G Vicario

    IE: apply stylesheet in dynamically inserted nodes

    Alvaro G Vicario, Aug 30, 2005, in forum: Javascript
    Replies:
    2
    Views:
    100
    Alvaro G Vicario
    Aug 31, 2005
Loading...

Share This Page