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

I am using two pages. My problem is to move from a new page to a previous page using back button. But, when I go back to previous page, the content present in the page are being cleared. I want the same content to be remained when I move back.

Plzzz anyone help me with an example code?


Regards,
Posted
Updated 4-Apr-11 23:11pm
v2

try this


XML
<asp:LinkButton
                ID="lnk_Back"  OnClientClick="history.go(-1);" runat="server">Back</asp:LinkButton>
 
Share this answer
 
Comments
Raj.rcr 5-Apr-11 4:03am    
I tried it in button.. Its not working..
Mahendra.p25 5-Apr-11 4:07am    
another Option is store that values in session and in the PageLoad of first page
check If session !=null then Bind all your values and
and make Session.clear(),Session[""]=null
Raj.rcr 5-Apr-11 6:02am    
No actually, my process is: First I am moving to 2nd page with the link button present in 1st page. And I have a back button in the 2nd page through which I need to move back to the 1st page. My problem is that when I move back to 1st page using back button, the same data should present over there(1st page). Hope u understood. Plz help
You have numerous of options to do that.

In order to get the general idea have a look at this page in msdn;

ASP.NET Session State Overview[^]

Option link[^]

A basic code example is;

C#
object sessionObject = Session["someObject"];
if (sessionObject != null) {
 myLabel.Text = sessionObject.ToString();
}
 
Share this answer
 
Comments
Raj.rcr 5-Apr-11 4:10am    
I am not able to understand... I am trying but not working
Orcun Iyigun 5-Apr-11 4:26am    
you can look at the tutorials in youtube.
A quick one for all types here; http://www.youtube.com/watch?v=_hK8wD5rcMg&feature=related
for session; http://www.youtube.com/watch?v=wCKGJIvP0k0&feature=related
for cookie; http://www.youtube.com/watch?v=iny6scBVi8k&feature=related
Hi,

when I go back to previous page, the content present in the page are being cleared. I want the same content to be remained when I move back.

This line Sounds like u want the Same state of a page when u click on Back button,

The Simple way is Whenever u Click on Next Button before Executing Response.Redirect() Line which will bring you on New page First you have to take all the values Which you want when you click on Back button into Session variable and When you click on BACK button you have to again assign those values which you have already stored in Session variable into your respective Controls....

Well it's little bit lengthy procedure but once you understand it it is a very easy thing for you.

All d Best.
I Hope this will help you.
 
Share this answer
 
Comments
Raj.rcr 5-Apr-11 6:03am    
My process is: First I am moving to 2nd page with the link button present in 1st page. And I have a back button in the 2nd page through which I need to move back to the 1st page. My problem is that when I move back to 1st page using back button, the same data should present over there(1st page). Hope u understood. Plz help
Orcun Iyigun 5-Apr-11 6:35am    
you had three answers basically solving your problem. you are not putting enough effort. dont expect us to write the code for you!
Raj.rcr 5-Apr-11 6:44am    
I dnt expect you to write the code for me. I just asked an example code. anyways, thanx for the help

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