2011-04-26 80 views
2

在頁面加載更改圖像我對btnpriv添加此代碼根據主題

if (Request.Cookies["switchstyle"] != null) 
{ 
    string i = Request.Cookies["switchstyle"].Value; 
    if(i == "1") 
     ThemeImageUrl = "~/ImagesW"; 
    else 
     ThemeImageUrl = "~/Images"; 
} 

上我寫的代碼

CipCalendar.TodaysDate = CipCalendar.TodaysDate.AddMonths(-1); 

StoreMonthValue(CipCalendar.TodaysDate.ToString()); // storing month in a cookie. 
//Month.Text = CipCalendar.TodaysDate.ToString(MONTH_FORMAT); 
imgMonth.ImageUrl = ThemeImageUrl + "/CalendarImages/" + CipCalendar.TodaysDate.ToString(MONTH_FORMAT) + ".gif"; 
SetMonthNavigateButtonVisible(); 
SetYearNavigateButtonVisible(); 
isNextMonth = false; 
SetCases(); 

其做工精細,日期正在改變形象,但是當我正在使用瀏覽器返回btn此代碼不工作..

基於主題變化當我按btnpriv以及瀏覽器返回btn日期應該改變這是不是現在發生在點擊瀏覽器返回btn

回答

0

有2認爲你可以做。

首先,當您更改主題時,使用重定向()重新加載頁面,用戶無法返回。當使用返回是合乎邏輯的,以便從緩存中重新加載頁面,以便看到前一圖像。

其次爲您的動態頁面禁用緩存。

public static void DisablePageCaching() 
{ 
//Used for disabling page caching 
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); 
HttpContext.Current.Response.Cache.SetValidUntilExpires(false); 
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); 
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
HttpContext.Current.Response.Cache.SetNoStore(); 

} 
+0

它,我用兩個主題,黑色和白色,背部主題一月,二月,三月黑色圖像不工作 – Rocky 2011-04-26 09:49:30

+0

是存在的,在白色一月二月三月黑白圖像是存在的,用我的代碼正在改變,但是當在黑色主題1月1日之後,我正在使用瀏覽器返回btn。三月白色圖像即將到來,不得在黑色主題上顯示黑色主題,僅黑色圖像顯示在黑色主題上。並沒有發生白色主題。 – Rocky 2011-04-26 09:54:25

+0

我應該在哪裏調用DisablePageCaching()我在頁面加載時調用它。 – Rocky 2011-04-26 10:17:04