本文介绍了preserving DropDownList的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页: Menu.aspx ,在那里我有相关的以下控件:

I have a webpage: Menu.aspx, where I have the following controls of relevance:


  • 某些值一个DropDownList

  • 一个按钮,它重定向我到一个名为Edit.aspx页面。

在我的 Edit.aspx 页,我有一个取消按钮,用户与下面的C#方法重定向回菜单页

In my Edit.aspx page, I have a cancel button, which redirects the user back to the Menu page with the following C# method

protected void btnCancel_click(object sender, EventArgs e)
{
    Response.Redirect("Menu.aspx");
}

我想要做的是,当我重​​定向我的用户回到Menu.aspx,我preserve DropDownList中的价值,他们选择的。

What I would like to do is when I redirect my user back to Menu.aspx, I preserve the value of the DropDownList that they selected.

在此先感谢!

编辑:理想情况下,我想做到这一点没有一个查询字符串(如果可能)

Ideally, I want to achieve this without a QueryString (if Possible)

EDIT2:我在想东西invovling一个视图状态或回传,但我不熟悉的

I was thinking of something invovling a viewstate or postback but I'm unfamiliar with those.

推荐答案

在名为的Response.Redirect(Menu.aspx); 您已经制作新请求previous页面没有哪一部分。这就像重新调用页面。

When you called Response.Redirect("Menu.aspx"); you were already making a new request which the previous page was not part. It's like calling the page anew.

您可以把会议的价值来Edit.aspx之前,或通过查询字符串值回

You can put the value in session before coming to Edit.aspx or pass the value back through query string

 Response.Redirect("Menu.aspx?dropdownvalue=123");

Menu.aspx ,你会检查?dropdownvalue = 123 存在并设置所选的项目该值

On Menu.aspx, you'll check if ?dropdownvalue=123 exist and you set selected item to that value

这篇关于preserving DropDownList的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:01