Another busy weekend - and using Dynamically loaded user controls the easy way (English)

Another busy weekend - and using Dynamically loaded user controls the easy way

Tuesday, 16 March 2004

//

Less than a minute

Well, spent the weekend working again - had a sudden stroke of inspiration about a work project, much refactoring later, I have a more stable and flexible implementation. I may write about this in more detail at a later date, got some pretty cool stuff going with Page templates etc... Until then, just a reminder about the most useful thing on the planet when using Dynamically loaded user controls - Denis Bauer's DynamicControlsPlaceholder. I've posted a link to this control a few times now, but I can't overemphasize how much faffing around it can save. Another reminder, if you want to load controls (using the Page.LoadTemplate() method) and have their events work, load the controls in PreRender (since that happens after the PostbackEvent has fired whereas OnLoad fires before) - and use the DynamicControlsPlaceHolder's ControlRestored event to rebind the event back on to the restored control. Pretty simple, but it's one of those questions I've answered quite a few times in the ASP.NET forum - and is a real gotcha for beginners. I'll probably post a little example project using this method and a couple of others when I get a chance.

logo

© 2025 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.