|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error: Multiple controls with the same ID '1' were found.I am getting the following error when dynamically adding
RequiredFieldvalidator control to a Table. Multiple controls with the same ID '1' were found. FindControl requires that controls have unique IDs I get this error only on validator control and not on labels or textbox, so if I was to replace the same control with a label or textbox, it works fine. Here is the code, case "RequiredFieldValidator": RequiredFieldValidator cReq = (RequiredFieldValidator)ctrl; cReq.ID = System.Guid.NewGuid().ToString(); mcell.Controls.Add(cReq); break; Thanks for your help! Vibs It is for this kind of situation that control designers would implement the
INamingContainer http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiinamingcontainerclasstopic.asp "Any control that implements this interface creates a new namespace in which all child control ID attributes are guaranteed to be unique within an entire application. " Show quoteHide quote "vibs" wrote: > I am getting the following error when dynamically adding > RequiredFieldvalidator control to a Table. > Multiple controls with the same ID '1' were found. FindControl requires that > controls have unique IDs > > I get this error only on validator control and not on labels or textbox, so > if I was to replace the same control with a label or textbox, it works fine. > Here is the code, > > case "RequiredFieldValidator": > RequiredFieldValidator cReq = (RequiredFieldValidator)ctrl; > cReq.ID = System.Guid.NewGuid().ToString(); > mcell.Controls.Add(cReq); > break; > > Thanks for your help! > Vibs Phillip,
I am not creating a new control. I am just using an existing RequiredValidator Control. Thanks Show quoteHide quote "Phillip Williams" wrote: > It is for this kind of situation that control designers would implement the > INamingContainer > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiinamingcontainerclasstopic.asp > > "Any control that implements this interface creates a new namespace in which > all child control ID attributes are guaranteed to be unique within an entire > application. " > > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "vibs" wrote: > > > I am getting the following error when dynamically adding > > RequiredFieldvalidator control to a Table. > > Multiple controls with the same ID '1' were found. FindControl requires that > > controls have unique IDs > > > > I get this error only on validator control and not on labels or textbox, so > > if I was to replace the same control with a label or textbox, it works fine. > > Here is the code, > > > > case "RequiredFieldValidator": > > RequiredFieldValidator cReq = (RequiredFieldValidator)ctrl; > > cReq.ID = System.Guid.NewGuid().ToString(); > > mcell.Controls.Add(cReq); > > break; > > > > Thanks for your help! > > Vibs try:
mcell.Parent = this; ASP renders the ID as ClientID (or UniqueID, I can never remember), which qualifies them via the IDs of the parental hierarchy. However, the parent must be non-null, so I am guessing that mcell has no parent at this point? Keith,
mcell.parent is a readonly property. I am adding the control to a cell in a table. I so see the mcell.parent has a uniqueid on each iteration. And again this is happening only for validator controls so something else is going on here.... Thanks Vibs Show quoteHide quote "Keith Patrick" wrote: > try: > mcell.Parent = this; > > > ASP renders the ID as ClientID (or UniqueID, I can never remember), which > qualifies them via the IDs of the parental hierarchy. However, the parent > must be non-null, so I am guessing that mcell has no parent at this point? > > > Sorry about that...forgot that it gets set during Controls.Add (I didn't
compile it to check)
SelectedValue which is invalid
Getting value from child control of formview Embedding CSS with inline code Reports and the ReportViewer Dataset from ObjectDataSource always null? GridView Data Binding at runtime Design Time referencing of Properties GUID and data controls DotNet & SDK install issue DrawEllipse gives inaccurate results for some radii |
|||||||||||||||||||||||