根据主题更改图像 [英] Changing image according to theme

查看:112
本文介绍了根据主题更改图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面加载我加入这个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(); 

} 

这篇关于根据主题更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆