2011-04-26 87 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