October 2010
Intermediate to advanced
1920 pages
73h 55m
English
You can dynamically load a User control at runtime and display it in a page. Imagine, for example, that you want to display different featured products randomly on the home page of your website. However, you want to display each featured product with a completely different layout. In that case, you can create a separate User control for each product and load one of the User controls randomly at runtime.
You load a User control with the Page.LoadControl() method, which returns an instance of the Control class that you can add to a page. Typically, you add the User control to a PlaceHolder control that you have declared on the page.
The PlaceHolder control was designed to do absolutely nothing. It simply ...