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. Advertisements

  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. Advertisements

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:
    626
    lucky
    Jan 12, 2005
  2. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    7,130
    Matt Berther
    Mar 5, 2005
  3. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,554
    Scott Allen
    Mar 4, 2005
  4. Mad Scientist Jr
    Replies:
    0
    Views:
    892
    Mad Scientist Jr
    Mar 22, 2006
  5. Replies:
    1
    Views:
    704
    Andrew Thompson
    Nov 19, 2007
  6. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    805
    Jonathan Wood
    Feb 2, 2010
  7. 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:
    414
    Victor Garcia Aprea [MVP]
    May 5, 2004
  8. Travis Pruitt

    Dynamically Adding User Control with Child User Control

    Travis Pruitt, Jan 13, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    300
    Travis Pruitt
    Jan 13, 2005
Loading...