Child control forms data

J

Johan Nordberg

I have made a custom template control which basically loads a web user
control and replaces some PlaceHolders with content that I specify in
the template control tag, like this:

<J2:Host runat="server" id="TemplateHost"
TemplateUrl="Templates/PageTemplate.ascx">
<J2:Content Runat="server" ID="Header" AttachTo="Header" Text="My
text"/>
<J2:Content Runat="server" ID="Content" AttachTo="Content">
This is my content
</J2:Content>
</J2:Host>

This works excellent for just content, but I need to have form field
in my content block as well. The problem is that when I post a form,
the Page that contains the Template Control doesn't recognize the form
fields as children of the page. Therefor event handlers for button
doesn't work, view state is not restored and form field are not
initialized with the posted value.

How do I redirect all the posted data from an child control in my
custom control, to the Page that hosts my control. I kind of would
like all events from my control not handled by the control to bubble
up to the page.

Please help with some ideas!

// Johan
 
J

Johan Nordberg

Thank you for replying.

I solved it by my self. The problem was that I added the controls by overriding Render, which was too late. I changed my code to add child controls in OnInit instead and that made it all work just as I had thought it would

However, event bubbling might still be interesting in other components

// Johan
 

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,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top