views:

430

answers:

2

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?

A: 

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

Greg Hurlman
I was thinking the same thing, except it would really hurt if i had to do that every time i put something in the modal window.
Per Hornshøj-Schierbeck
A: 

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.

Per Hornshøj-Schierbeck