Wednesday 4 January 2012

Changing Master Page at Runtime

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

Master.FindControl("nameLbl").Visible = true;

No comments:

Post a Comment