Adding user controls at runtime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Group,

I'm somewhat new to C#, and I was wondering if anyone would know how I could add an ascx control to a Web form at runtime?

Thank you in advance,
Jim
 
Look for the Page.LoadControl() method - it takes the virtual path to a
control and returns a control instance.


//psuedo-example:
Control ctrl = Page.LoadControl("mycontrol.ascx");
placeHolder1.Controls.Add(ctrl);



JimMace said:
Group,

I'm somewhat new to C#, and I was wondering if anyone would know how I
could add an ascx control to a Web form at runtime?
 
Back
Top