Posts

Showing posts with the label UserControls

ASP.NET User Control with Template Content

Asp.net user controls are great.  I use them all the time when working on .net websites.  I was working on a site using the asp.net ajax extender toolkit.  I created a panel that could be expanded collapsed with a button click.  I inserted a few into the site and liked them so much I made some more.  Well after the 7th panel it started getting tedious.  What a perfect place for a user control.  The problem was I needed to be able to place whatever custom content I wanted inside the panel.  After much searching around I wasn't finding what I wanted.  The answer it turns out is an asp.net user control with custom templates. Create a new user control for your asp.net site.  Mine is called CollapsiblePanel.  In the code behind for the page you need to add a new class MessageContainer that inherits from Control and implements the INamingContainer Interface .   Then in the user controls OnInit method you need to check for cont...