Click here to Skip to main content
15,896,415 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All

C#
protected void btnPreview_Click(object sender, EventArgs e)
    {

        ArrayList array = new ArrayList();

        array.Add(txtAD.Text);
        array.Add(txtASO.Text);
        array.Add(txtController.Text);
        array.Add(txtGPS.Text);
        array.Add(txtTAP.Text);

        Session["ArrayList"] = array;
        ViewState["ArrayList"] = array;
        Response.Redirect("~/Preview.aspx");

}
till now it fine

In the Preview page i have a Edit Button. by cliking on i will redirected my page again to the Previous page.. there the text box values are not there..
i want to persist the textbox values between different page loads..

I know that i shoiuld use view state.. but could't able to implement them.
Please help me in that.

Thanks
Posted
Comments
Prerak Patel 7-Apr-11 7:24am    
And what code you have on Edit button?
Sergey Alexandrovich Kryukov 7-Apr-11 7:53am    
Tag ASP.NET!

You shouldn't use ViewState because you're navigating between different pages. Use Session instead.
 
Share this answer
 
Comments
info.manyam 7-Apr-11 7:27am    
HiI used Sessions to Persist the data between pages.
But what my need is
Ex:

On Registration Form we will enter all the required info and i have a Preview button there to preview the data befor submitting it into the server. if any errors i go back to the page and edit the info then i come back to the preview page.. to edit the info i should have the data in text boxes.. i could not able to get it..
please help me in this
http://msdn.microsoft.com/en-us/library/ms750637.aspx[^] or <input type="button" value="Back to Previous Page" onClick="javascript: history.go(-1)"> on Edit button will be helpful to you.
 
Share this answer
 
i agree with Jim

try in this way

On Click Of btnPreview
session["Name"]=Convert.tostring(txt.text);

Redirect to nextPage 

//do your work 

Redirect to previous Page 

//in the Page Load Check 

if(session["Name"]!=null)
TextBox1.text = Session["Name"];
//clear that Session 

Session["Name"]=null;
Session.clear(); 
 
Share this answer
 
Comments
info.manyam 7-Apr-11 7:45am    
Hi.

Here is my Code On Preview Button Click
protected void btnPreview_Click(object sender, EventArgs e)
{

ArrayList array = new ArrayList();

array.Add(txtAD.Text);
array.Add(txtASO.Text);
array.Add(txtController.Text);
array.Add(txtGPS.Text);
array.Add(txtTAP.Text);

Session["ArrayList"] = array;
Response.Redirect("~/Preview.aspx");

THen the page is redirected to Preview Page.
On Preview Page

on Page Load
ArrayList array1 = new ArrayList();
array1 = (ArrayList)Session["ArrayList"];
lblAD.Text = Convert.ToString(array1[0]);
lblASO.Text = Convert.ToString(array1[1]);
lblController.Text = Convert.ToString(array1[2]);
lblGPS.Text = Convert.ToString(array1[3]);
lblTAP.Text = Convert.ToString(array1[4]);

and i Have a Edit abutton to edit the data on First Page..

How to enable the values in textboxes even on different page loads.

Pls provide solution.. i think u got wat i want..
Mahendra.p25 7-Apr-11 8:00am    
as Prerak has suggest .You can take one simple html input tag type = button

<input type="button" value="Back to Previous Page" önClick="javascript: history.go(-1);"/>

and call javascript: history.go(-1); this function it will help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900