LoadControl and Multiple IDs in UserControls Error

N

Nestor

Hello,

I have a usercontrol to load dynamically into a webform. In the usercontrol
there is a textbox. I need to load 2 instants of the same usercontrol into
the form.

When a command button, which resides on the form container, is clicked. The
text content in the two different instants of the user control should be
retrieved...

Loading the form into the webform seems ok, but when i click on the button,
I get this error

Multiple controls with the same ID '(id of the control)' were found.
FindControl requires that controls have unique IDs.

How do I get around this?

thanks.
Nestor.
 
N

.net noobie

add the id's to the textbox's dynamicly

u can use
dim i as int32 = 0
for each control in dynamicControls
dim myControlId as String = "myControlId" & i.ToString
myTextBox.Attrbuites.Add("id", myControlID)
Next


the above is just a quick bit of code i typed out of my head, so it may not
be 100% correct, but it should give the idea of how to dynamiclly set the
Control ID's
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top