Load CustomControl at runtime

  • Thread starter Thread starter Gabriel
  • Start date Start date
G

Gabriel

Hello,

I create a user control, no problem at design time.

But when I try to load at runtime, no error but I don't see it.

The code is :

protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
_myUserControl = new myUserControl();
Page.Controls.Add(_productSearch);

}
}

Any idea why ?

Thanks,
 
Hi Gabriel,

Try to use LoadControl() method and do not forgot to register your
usercontrol with <%@ Register Src="" TagName="" TagPrefix="" %>

Regards,
Alex.

Gabriel напиÑав:
 
Back
Top