根据主题更改图像

根据主题更改图像

问题描述:

在页面加载我加入这个code

On page load i am adding this code

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

在btnpriv上我写了code

on btnpriv on i am writing the code

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该code不工作。

its working fine, date is changing on image, but when i am using browser back btn this code is not working..

基于主题的变化,当我preSS btnpriv以及浏览器的后退BTN日期应该改变其未在浏览器点击现在发生回BTN

based on theme change when i press btnpriv as well as browser back btn date should change which is not happening now on click of browser back btn

有2认为你可以做的。

首先,当您更改主题,然后使用重定向()重新加载页面和用户不能回去。当使用回去是合乎逻辑的,所以你看到的previous图像从缓存重新加载页面。

First when you change the theme, then use a redirect() to reload the page and user can not go back. When use go back is logical to reload the page from the cache so you see the previous image.

二禁用缓存动态页面。

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(); 

}