Template control in ASP.NET hiding content from page

I'm writing my own Modal Popup as a template control in ASP.NET. I got two template containers - one for the heading of the window and one for the actual control i want to display in the modal window (let's call it the form control). The form controls can contain server controls like buttons, textbox'es etc.

It works well, except when i want to access the form control in my web page. My codebehind won't recognize the content in the template control - just like it won't in, say a Repeater. So i figured a Panel control works just like what i need, except the Panel control only has "one container" and i'd really like to be able to set both a header and the content (form control).

I figured i could overwrite the Panel control to add my own html but that would limit my header to be something encodeable in an attribute. So is my best bet really to expose the Heading as just a property, instead of a template and thus being limited in what i can write for heading?

Upvotes: 0

Views: 850

Answers (2)

I ended up overriding the Panel control, accepting that i can only "pass" one set of controls as its children. Also i had to make the heading a property i set as an attribute on the modalpopup control.

Even though i couldn't solve it the way i wanted to, i think the solution is good enough.

Upvotes: 0

Greg Hurlman
Greg Hurlman

Reputation: 17804

Just as you can with a repeater, try using the ParentControl.FindControl(...) method to get the control you desire.

Upvotes: 0

Related Questions