October 2010
Intermediate to advanced
1920 pages
73h 55m
English
You can load a User Control dynamically by using the Page.LoadControl() method. You can cache dynamically loaded User Controls in the same way that you can cache User Controls declared in a page. If a User Control includes an <%@ OutputCache %> directive, the User Control will be cached regardless of whether the control was added to a page declaratively or programmatically.
However, you need to be aware that when a cached User Control is loaded dynamically, ASP.NET Framework automatically wraps the User Control in an instance of the PartialCachingControl class. Therefore, you need to cast the control returned by the Page.LoadControl() method to an instance of the PartialCachingControl class.
For example, ...
Read now
Unlock full access