Reputation: 4063
Im using ASP.NET 3.5 and WebForms + jQuery, when I added a UserControl (ACSX) in runtime using a button click event, the event page_load in the custom acsx show false in IsPostBack, so when its happens the customs controls inside the control could not initialize. Then I show the acsx in a modal dialog trough jQueryUI.Modal
Any ideas how to force IsPostBack to false, in the control load?
Regards.
Upvotes: 1
Views: 600
Reputation: 2875
You could add a session variable that works alongside IsPostBack i.e.
Control that is creating control (Code)
Session["reload"] = true;
placeholder.Controls.Add(LoadControl("~/path/to/control.ascx"));
UserControl code
protected void Page_Load(object sender, EventArgs e){
var reload = Session["reload"];
if(!IsPostback || (reload != null && (bool)reload))
{
Session["reload"] = null;//reset the session var
//do load
}
}
Minor modification and ability to reload on demand
Upvotes: 2