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?
     
    Kikoz, Nov 17, 2004
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.