Click here to Skip to main content
15,917,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have developed a web application and the when user goes back all the entries are expired. I want that when user goes back, all the entries they entered on the last page are viewable.

For example if a user entered like :

first page : User Name,User_ID<br />
Second Page : Q1<br />
Third Page : Q2<br />
Fourth Page : Q3<br />
Fifth Page : Q4<br />
Sixth Page : Complete


In database answer will save according to User ID. Query is like :
Update Q1= "value" where User_ID = @User_ID
Update Q2= "value" where User_ID = @User_ID
Update Q3= "value" where User_ID = @User_ID



So if user want to edit Q2 again then he can go back and edit the last answer but in my case when user go back then his last answer will save in database but not on the page. So i want whenever he want to review or edit the previous answers before complete he can go and edit it.

Any help is appreciated.

Thanks.
Posted
Updated 18-Jan-12 23:50pm
v3
Comments
Rajesh Anuhya 19-Jan-12 5:39am    
Added pre tags.
Jephunneh Malazarte 19-Jan-12 6:20am    
question. if you have 5 questions meaning you have 5 aspx pages? if yes, have you tried using content place holder?

If user hits back button of browser, then he can see the values, but I think that you may have one back button in all pages which redirects it to the previous page.

As a button is clicked, always a post back happens; so the page again reloads with no values.

For your problem, you can store all the values in session variables when you move to next page.
And when back button is pressed(i.e. the previous page loads), you have to check for the existence of the session values in previous page and if they exist, then give their values to appropriate controls in your pages.
 
Share this answer
 
Comments
BobJanova 19-Jan-12 7:07am    
It's actually browser dependent whether it will reload values into a page you go 'back' to. I think Chrome and Firefox will only re-fill the form if it retrieves the page from cache, so if it's marked as non-cachable by the server then it will reload it and not re-fill. The questioner may have to update his template or ASP config to make these pages cachable (i.e. don't send the Pragma: no-cache and set the cache expiry to at least a few minutes in the future).
Thanks @tnitin55....
tnitin55 20-Jan-12 5:31am    
Thanks for the reply and can you please send me a test code for use of session because i am confused how to use session in this case and you are right i am using back button on the page and i was talking about the same.
or give me any link witch help me to use session.
Ok I will do. But do you need it urgently????

If you can send me your codes, then I can do it fast. Otherwise it will take some time....
ok here I can tell you how to do it.
I think you must have written - Response.Redirect("Next_Page.aspx"); somewhere after getting the values of the controls.

Just before this line add the codes for the conrol values u want to store like below -

Session["UserName"] = txtUserName.Text;
Session["UserID"] = UserID;
and so on.....

And then in previous page load check whether these value are in session or not, then fill values to appropriate controls as below...

Inside Page_Load() ----
if(Session["UserName"] != NULL)
{
txtUserName.Text = Session["UserName"].ToString();
}
if(Session["UserID"] != NULL)
{
txtUserID.Text = Session["UserID"].ToString();
}
and so on.....
To restore those values when revisiting a page, you need to load them from the database and populate the fields in the output with the values you retrieved.
 
Share this answer
 

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