Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can you change a Master page dynamically in which event
of page life cycle?

Answers were Sorted based on User's Feedback



How can you change a Master page dynamically in which event of page life cycle?..

Answer / ss

In Page_PreInit(object sender, EventArgs e) Event ...

Is This Answer Correct ?    14 Yes 4 No

How can you change a Master page dynamically in which event of page life cycle?..

Answer / ashutosh tripathi

Unfortunately there is not built in support to change page
themes at runtime. Here is a simple code which can be used
to change page themes at runtime:
At first though we may say we can easily achieve this by
coding it in Page_Preinit Event as shown below.

protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme = "Black"

}

But problem with this is we cant assign value from dropdown
box because Page_Preinit event is fired much before
dropdown has changed value.

To resolve this issue, just use the following steps:
1-Create one session variable which will hold current theme
value
2-On selection change event of dropdown combo box , assign
value form combo box to session variable.
3-During Page_preInit Event assign this variable value to
Page.Theme property.
4-Stop page loading and reload same page again using
server.transfer method as shown below


protected void Page_PreInit(object sender, EventArgs e)
{
string thm;
thm = (string)Session["themeSelected"];
if (thm != null)
{
Page.Theme = thm;
DropDownList1.Text = thm;
}
else
{
Session["themeSelected"] = DropDownList1.Text;
Page.Theme = "Blue";
}

protected void DropDownList1_SelectedIndexChanged(object
sender, EventArgs e)
{
Session["themeSelected"] = DropDownList1.Text;
Server.Transfer(Request.FilePath);

}


Is This Answer Correct ?    8 Yes 1 No

Post New Answer

More ASP.NET Interview Questions

How to do state management in ASP.NET?

0 Answers   BirlaSoft,


Asp.net - How to find last error which occurred?

1 Answers   Abacus,


What event fired during, when datagrid click?

1 Answers  


What is a web server? What are the load limits in it?

0 Answers   Wipro,


What are the types of caching in asp.net?

0 Answers  


What is anonymous authentication?

0 Answers  


Can we have a web application running without web.config file?

0 Answers  


How we can set Different levels of Authentication in .Net? What are the difference between Windows Authenticatin, Passport Authentication and Form Authentication?

1 Answers  


step to create a strong name?

1 Answers  


How would you enable impersonation in the web.config file?

0 Answers  


What are the intrinsic objects present in ASP.NET

1 Answers   IBM,


What does session_start () do?

0 Answers  


Categories