RegisterRequiresPostBack and child custom controls

C

Cathead

I have a composite custom control that creates other custom composite
controls within CreateChildControls(). 2 questions:

1) Must you explicitly call Page.RegisterRequiresPostBack for every control
that is interested in postbacks?

I assumed from the documentation that the ASP.NET page framework would call
LoadPostData on every IPostBackDataHandler that was a part of the control
tree. This was not happening for my custom controls until I registered them
with Page.RegisterRequiresPostBack within the control's OnInit(). Is this
expected behavior?

2) Registering with Page.RegisterRequiresPostBack() caused my top-level
custom control's LoadPostData to be fired, but not those of the child custom
controls. Within my top-level control, do I have the responsibility to
propogate the LoadPostData() to child controls? For example:

public virtual bool LoadPostData(string postDataKey, NameValueCollection
postCollection)
{
foreach(Control c in Controls) {
c.LoadPostData(postDataKey, postCollection);
}
}


Thanks in advance.

CH
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top