protected override void OnPreRender(System.EventArgs e) { if (nextView == null) { return; } if (currentView != nextView) { // Show the next view NUserControls.UserControl nextControl = (NUserControls.UserControl)LoadControl("UserControls/" + nextView + ".ascx"); nextControl.ID = "ID_" + nextView; placeholder.Controls.Add(nextControl); nextControl.CurrentController = this; nextControl.DataBind(); // Delete last view NUserControls.UserControl lastControl = (NUserControls.UserControl)placeholder.FindControl("ID_" + currentView); placeholder.Controls.Remove(lastControl); currentView = nextView; } else { Control currentControl = placeholder.FindControl("ID_" + currentView); currentControl.DataBind(); } ViewState["CurrentView"] = currentView; ViewState["NextView"] = nextView; }
private void Page_Load(object sender, System.EventArgs e) { if (ViewState["CurrentView"] != null) { currentView = (string)ViewState["CurrentView"]; Context.Items.Add("currentView", currentView); nextView = (string)ViewState["NextView"]; Context.Items.Add("nextView", nextView); } else { // Go to Home) currentView = WebViews.STARTUP; nextView = null; } if (Request.QueryString["action"] != null) { currentView = Request.QueryString["action"]; nextView = null; } // Make the right control visible NUserControls.UserControl userControl = (NUserControls.UserControl)LoadControl("UserControls/" + currentView + ".ascx"); userControl.ID = "ID_" + currentView; // // if (currentView == "Error") // { // LabelStatus.Controls.Add(userControl); // } // else // { placeholder.Controls.Add(userControl); // } userControl.CurrentController = this; }