Đó là một câu trả lời rất muộn, nhưng tôi nghĩ bạn sẽ thích này ..
Bạn có thể thay đổi Theme of the page trong sự kiện PreInit, nhưng bạn không sử dụng trang cơ sở ..
Trong trang chính tạo danh sách thả xuống có tên ddlTema, sau đó viết khối mã này trong Global.asax của bạn. Xem cách hoạt động của phép thuật :)
public class Global : System.Web.HttpApplication
{
protected void Application_PostMapRequestHandler(object sender, EventArgs e)
{
Page activePage = HttpContext.Current.Handler as Page;
if (activePage == null)
{
return;
}
activePage.PreInit
+= (s, ea) =>
{
string selectedTheme = HttpContext.Current.Session["SelectedTheme"] as string;
if (Request.Form["ctl00$ddlTema"] != null)
{
HttpContext.Current.Session["SelectedTheme"]
= activePage.Theme = Request.Form["ctl00$ddlTema"];
}
else if (selectedTheme != null)
{
activePage.Theme = selectedTheme;
}
};
}
@this. __curious_geek, tại sao thích làm điều đó trong Page_Load không phải Pre_Int? –