Loading User Controls into page

Hi everyone,

I have a question related to loading an "ascx" into an "aspx" page.

I have the page "default.aspx". When I press a button on this page I load into a placeholder the "ascx" file "dummy.ascx".

Button_click(....)
{
placeHolder.Controls.Add(Page.LoadControl("dummmy.ascx"));
}

In this dummy.ascx I have a button. When I press this button the event associated with it is not fired because I am not loading again the page in Page_Load.

I appreciate a good solution related to this issue
Thank you



Answer this question

Loading User Controls into page

  • JamesZ

    If you are loading the control dynamically then you need to load the control in the Postback also otherwise the event is not going to be fired.


  • Loading User Controls into page