浏览器上的后退按钮是回发?

时间:2016-04-20 15:14:32

标签: jquery asp.net cookies drop-down-menu postback

我有一个网站http://www.dendy.com.au/Page/Home,在下拉框中有2个选项,它通过获取movieid cookie来加载会话数据(newtown),这很好。当我更改选项时,它会加载其他影院会话数据。

问题是,当我加载第二个会话数据(Opera Quays)并点击一个电影然后按回浏览器(大多数人这样做)它再次使用Newtown数据加载主页时由于cookie但在Dropbox它仍然选择了Qpera Quay,即使在inspect元素Newtown选项中选择了值。

我怀疑这是由于页面的缓存造成的。因此,它将选择我之前选择的下拉选项,但从cookie中加载newtown的会话数据。

如果有办法解决它? 这是我的代码

 protected void Page_Load(object sender, EventArgs e)
{
    // get cinemaid  from  cookie in the usercontrol base class 
    IList<ORM.Cinema> cinemaList = DAL.DataClasses.CinemaGroup.GetCinemasInGroupByCinemaId(cinemaId);
    //if there's only 1 cinema, hide the cinema selection area
    if (cinemaList.Count() == 1)
    {
        SelectCinemaDiv.Visible = false;
    }
    else
    {
        //set the default cinema dropdownlist selection
        CinemaDropDownList.DataSource = cinemaList;
        CinemaDropDownList.DataBind();
        CinemaDropDownList.SelectedValue = cinemaId.ToString();
        cinemaId = new Guid(CinemaDropDownList.SelectedValue);
    }

        //loads sessions data
    SessionTimeLiteral.Text = LoadCinemaSessionsDirect.LoadCinemaSessionsForOneCinema(cinemaId.ToString(), thisInstance.IncludeElementInstanceId.ToString());

我尝试使用!回发但没有运气

//if there's only 1 cinema, hide the cinema selection area
    if (!IsPostBack)
    {
        if (cinemaList.Count() == 1)
        {
            SelectCinemaDiv.Visible = false;
        }
        else
        {


            //set the default cinema dropdownlist selection
            CinemaDropDownList.DataSource = cinemaList;
            CinemaDropDownList.DataBind();
            CinemaDropDownList.SelectedValue = cinemaId.ToString();
        }
    }
    else
    {
        cinemaId = new Guid(CinemaDropDownList.SelectedValue);
    }

1 个答案:

答案 0 :(得分:0)

为什么不使用Session变量来存储用户选择的内容?然后在页面加载的所有页面上,您可以通过检查会话数据来交换它吗?

Session["UserSelection"] = CinemaDropDownList.SelectedValue;