我是通過DropDownList控件的回發來切換主題的,將選擇值存入Cookie后,在頁面Load事件中通過判斷頁面是否首次加載來設置主題(默認還是新選擇)。主題的設置是在自定義頁面基類中的PreInit事件中應用private void Page_PreInit(object sender, EventArgs e) { HttpCookie preferredTheme = Request.Cookies.Get("PreferredTheme"); if (preferredTheme != null) { Page.Theme = preferredTheme.Value; } } public BasePage() { this.PreRender += new EventHandler(Page_PreRender); this.PreInit += new EventHandler(Page_PreInit); }調試時的情況是,若單個頁面調試,主題的應用是沒問題的,當在頁面中導航到其他站點時就不行了,總是需要重新選擇主題
跳轉頁面時頁面無法應用到主題,總是需要在當前頁面重新選擇主題
慕婉清6462132
2018-08-22 05:06:52