Introduction


Some times we have to change MasterPage of a Page at runtime 
by user code below is the trick for changing master page at runtime 


<PRE>There is a Event <CODE>Page_PreInit</CODE> who will be executing just before 
the page render. 
We have to do code in this event like below

protected void Page_PreInit(object sender, EventArgs e) 
{ 
 if (Membership.GetUser() == null) //check the user weather user is logged in or not
    this.Page.MasterPageFile = "~/General.master";
 else
    this.Page.MasterPageFile = "~/myMaster.master";
}
we can change the content of master page from inherited page too like below

<CODE>Master.FindControl("nameLbl").Visible = true;</CODE>