To accomplish this you have to use the Page.MasterPageFile property through Page_PreInit event.The Page_PreInit event is the earliest point in which you can access the Page lifecycle.For this reason,this is where you need to assign any master page that is used by any content pages.The Page_PreInit is an important event to make this,it can set as follows;
VB
Protected Sub Page_PreInit(ByVal sender As object,ByVal e As System.EventArgs)
Page.MasterPageFile = "~/MyMasterPage.master" ;
End Sub
C#
protected void Page_PreInit(object sender , EventArgs e)
{
Page.MasterPageFile = "~/MyMasterPage.master" ;
}
VB
Protected Sub Page_PreInit(ByVal sender As object,ByVal e As System.EventArgs)
Page.MasterPageFile = "~/MyMasterPage.master" ;
End Sub
C#
protected void Page_PreInit(object sender , EventArgs e)
{
Page.MasterPageFile = "~/MyMasterPage.master" ;
}
No comments:
Post a Comment