ASP.NET Previous Page
I have page and I am displaying the same page for n number of times and binding Various Data.
There is a back button on the page, When I click on it it should just take the page where it should diplay the prev开发者_高级运维ious data in the controls.
I tried Server.Transfer, Response.Redirect(), But they are taking to the page I wanted but not to the immediate previous page.
Please help.
Thank you Hari Gillala
May be this helps;
protected void Page_Load(object sender, EventArgs e)
{
this.btnBack.OnClientClick = "javascript:window.history.go(-1);return false;";
}
Would doing it on the client side suffice? Just use history.go(-1)
on click of the button.
Server side: You can store the data which has to be bound to the controls in the session.Create session variables before rendering the pages, give different names to the session variable, may be you can use static variable for naming..
Why don't you utilize History object of JavaScript?
http://www.javascriptkit.com/jsref/history.shtml
http://www.defaultdotaspx.com/Answer.aspx?QuestionType=JavaScript&QuestionID=264
http://www.developertutorials.com/questions/question/q-147.php
Are you binding "various data" via AJAX?
Hope this helps!
I'm guessing that what you mean in your question is: I have a bunch of filters on my page and every time a filter gets changed I want to create a new item in the browser history so I can use the Back button to go back through my filters.
Have a look at the AddHistoryPoint method (+ overloads) of the ScriptManager object. This method allows you to save the state of your controls into a collection and save that into a URL that gets inserted into your browser's history collection, so that you can then retrieve it when the Back button is pressed and reload the state into the controls on your page.
精彩评论