ID of dynamically inserted user control

  • Thread starter Thread starter Bijoy Naick
  • Start date Start date
B

Bijoy Naick

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
 
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?
 
Back
Top