English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm trying to make a survey consists of 2 pages. I wrote the code for the first page to store every answer for a question in session object. So that when the user hits "Back" from the second page, the first one will view the stored values.
The problem is it doesn't work. Please help.
PS: I know it's a stupid way, but it's a homework. Thank's ;)
Here is the code.

2006-10-30 04:11:53 · 1 answers · asked by Doublethink..!! 1 in Computers & Internet Programming & Design

public partial class travel : System.Web.UI.Page
{
string nextVacation;
string vacationType;
string budget;

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.QueryString["surveyType"];

DropDownList1.SelectedValue = nextVacation;
ListBox1.SelectedValue = vacationType;
TextBox1.Text = budget;
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["nextVacation"] = DropDownList1.SelectedItem;
Session["vacationType"] = ListBox1.SelectedItem;
Session["budget"] = TextBox1.Text;
Response.Redirect("travel2.aspx?surveyType=" + Label1.Text);
}
}

2006-10-30 04:12:21 · update #1

1 answers

Well I guess the first question would be is - do your pages and application have session state enabled?

Your pages.. up in the page directive should say EnableSessionState="true"

But I do have to say... you really don't want to be doing this in this fashion. With the asp:panel object, you should not even need to query out to another page to get info like this. Make the controls on your page part of the page that needs this info, then show the panel with the controls when the point comes to collect that info from the user.

Drop the info from the controls into the ViewState object, and you've got a bulletproof info collection system that will surive any session timeouts, or for that matter, even IIS restarts.

2006-10-30 12:48:31 · answer #1 · answered by evolver 6 · 0 0

fedest.com, questions and answers