Click here to Skip to main content
15,890,399 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
Second Page : Q1
Third Page : Q2
Fourth Page : Q3
Fifth Page : Q4
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.

for this i have used this solution...........

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.....

For ending the session i have used session.abendon property on the last page and on the terminate page of the application.

It work's but it saves the value i have entered for every time i use this application and what if more then one user use this application at the same time, because it show's all the time same value stored in the session ?


Any help is appreciated.

Thanks.
Posted
Comments
krumia 21-Feb-12 3:12am    
Appreciate if you could format the code using the pre tags. They are at the top of the editor.

1 solution

Values stored in the Session are just that - they are specific to that user, via that connection, until he goes away or the session times out. If he comes back to the same page from the same IP address within the session timeout period and IIS has not been restarted, it is possible (but not guaranteed) that he will retrieve the previous values. At no time will Session values be shared between different users.

If you want the values saved from connection to connection, then store them as cookies - these reside on the client, so are specific to him, and will be retained for as long as you like.
If you want the session to definitely restart, then clear the session variables explicitly when you load the first page, or set them to sensible defaults.
 
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