A control cannot modify its parents' control collections

GornHorse

Centurion
Joined
May 27, 2003
Messages
105
Location
Australia
G'Day,
Ok. Something that I can't find much info on, but am hoping someone has the skills for me...

I have a custom combobox (cbDB) control that has several child controls. One of these child controls, btnPoster is an htmlInputButton.

Within my asp.net application, the combobox control is added to the form, but in the codebehind, I reference the child control as follows:
public withevents cbDBBtnPoster as new htmlInputButton

Then, I assign it the following:
cbDBBtnPoster = cbDb.btnPoster

Now, as this child control, cbDBBtnPoster is not rendered in the form, I need to be able to reference this from the client-side through a javascript function.

I have tried several alternatives to get this control to be able to be referenced from the client-side, and am now up to this one, which i believe is the most promising option, but just trying to figure it out is, I fear, out of my depth... That's where you come in.

Anyway, in the form_load event (after i have declared the control and assigned its' value), i have the following:
Page.Controls.Add(cbDBBtnPoster)

Then, when i run the application, i get the following error:
'A control cannot modify its parents control collections.'

The stack trace is as follows:
this.controls.add(btnPoster);

(NB: this stack trace references the control class where the btnPoster child control is added to the control).

I know that this has something to do with the fact that btnPoster is a child control, but how can i ensure that the cbDBBtnPoster control will be able to be referenced by the client-side?

BTW, This is really urgent...

Cheers,
Michelle
 
Back
Top