protected void Page_PreInit(object sender, EventArgs e)
{
Page.MasterPageFile = "~/MasterPage.master";
}
Interviews4 answers
Master pages can be changed dynamically or not?
4 Answers
jitendra patelPosted Aug 13, 2010, 4:18 AM EDT
this code write before page_Load event
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/MasterPage.master";
}
jitendra patelPosted Aug 13, 2010, 4:17 AM EDT
Master pages are a feature in ASP.NET 2.0. They allow you to easily create a consistent feel throughout our website. They also provide an easy way to set/change the master pages at runtime. This is achieved by setting the MasterPageFile property of a page in the PreInit event.
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/MasterPage.master";
}
PEEYUSH MISHRAPosted Jul 21, 2009, 1:17 AM EDT
Raghvendra,
off course you can do dynamically.
MasterPage masterPage = new MasterPage();
masterPage.MasterPageFile = "abc.master";
..
..
Bishwajit SahaPosted Jun 23, 2009, 5:03 AM EDT