2 skin files in 1 page in Asp.net
I have a skin file in <%@Page Theme="Theme1"%>
I have two buttons. One for Theme1.skin and another for Theme2.skin.
If i press button 1, Theme should be changed to Theme1.skin
If i press button 2, Them should be changed to Theme2.skin
开发者_开发技巧I wroete this Page.Theme="Theme1";
on click event of button 1.
Then, i was told that could only be written in PreInit
method.
Any idea?
Listen to what you've been told. You need to set the theme in PreInit of the page lifecycle. After that it is not possible
This might get you in the right direction of solving you problem. The comments are also good to read. More precisely this comment.
You can try to set the theme name in a session, force refresh page and load it in page_init
protected void Page_PreInit(object sender, EventArgs e)
{
var themeName = Session["themeName"];
if (thm != null)
{
Page.Theme = themeName.ToString() ;
}
}
and
protected void Button1_Click(object sender, EventArgs e)
{
Session["themeName"] = "Theme1";
Server.Transfer(Request.FilePath);
}
similarly for Button2's Click, set session object to "Theme2"
精彩评论