How to Load User Control Dynamically

If you have created a User Control (.ascx) and you want to add them on page dynamically on the page, you can use LoadControl method of Page class

To add User Control dynamically on the page:

headerControl = Page.LoadControl("HeaderControl.ascx");

To add User Control dynamically exactly where you want on the page use PlaceHolder control




About author

User avatar

Waqas Anwar

Founder of, Senior Consultant, Microsoft .NET and Web Technologies