How to Load User Controls dynamically?

 Posted by vishalneeraj-24503 on 12/21/2013 | Category: ASP.NET Interview questions | Views: 791 | Points: 40
Answer:

With the hrlp of LoadControl of Page class,we can dynamically Load any User Controls:-

For Example:-
protected void Page_Load(object sender, EventArgs e)

{
Control myCtrl = null;
myCtrl = Page.LoadControl("~/UserControls/UcTeamControl.ascx");

Page.Controls.Add(myCtrl);
}

Where,UcTeamControl.ascx is my User Control.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response