Friday 7 December 2012

Changing Master Page on Runtime


Changing Master Page on Runtime


Use following code:


protected void Page_PreInit(object sender, EventArgs e)
{
if (Session["user"] == null)

this.Page.MasterPageFile = "~/MasterPage2.master";

else

this.Page.MasterPageFile = "~/MasterPage1.master";

}


The key here is to put the code in Page_PreInit.


References:

      http://forums.asp.net/p/1140254/1832376.aspx
 

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top