BuildManager is a class located in System.Web.Compilation namespace and contains a method named CreateInstanceFromVirtualPath. Using this static method, you may create instances of your UserControl, Page, Generic Handler or those kind of stuff. This might be useful in case you need to create some controls on the fly, etc.

The following piece of code shows how to use it.

UserControl instance = (UserControl)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath("~/Controls/Somefile.ascx", typeof(UserControl));

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.