Changing image according to theme
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";
}
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";
SetMonthNavigateButtonVi开发者_如何转开发sible();
SetYearNavigateButtonVisible();
isNextMonth = false;
SetCases();
its working fine, date is changing on image, but when i am using browser back btn this code is not working..
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
There are 2 think that you can do.
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.
Second disable the cache for your dynamic pages.
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();
}
精彩评论