Home All Groups Group Topic Archive Search About

LoadControl and Multiple IDs in UserControls Error

Author
10 Nov 2005 8:49 AM
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.

Author
12 Nov 2005 1:58 AM
.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

Show quoteHide quote
"Nestor" wrote:

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