i have requirment where i want to maintain all values enter by user in textbox will be maintain even if user navigate to other pages.eg.
User has enter data one quote 1 page and move to quote 2 and if he click on browser back button i want to miantain all data enter by user on quote1 and want to assign to appropirate control
On your ScriptManager, you need to set EnableHistory="true". Then, on the buttons that change from page1 to page 2 (to print page #3), you have to invoke ScriptManager.GetCurrent(Page).AddHistoryPoint("KeyName", value);
This saves the back button history state.
Now you have to override the OnNavigate event of the ScriptManager (or ScriptManagerProxy if your ScriptManager is in a MasterPage). When navigating, you have to restore the user's previous state manually.
The default behavior of the back button is what you are seeing -- it goes to the previous URL loaded in the browser. When you are using UpdatePanels, this URL doesn't change.
You can also google against ScriptManager, EnableHistory, AddHistoryPoint, and OnNavigate.
since the SP1 update for .NET 3.5 you have the History control for AJAX. This was specifically crafted for this task:Introduction to ASP.NET
AJAX History.
Nikhil86
Member
70 Points
65 Posts
Maintain values on Browser Back button
Jan 02, 2013 02:15 AM|LINK
Hi Friends
i have requirment where i want to maintain all values enter by user in textbox will be maintain even if user navigate to other pages.eg.
User has enter data one quote 1 page and move to quote 2 and if he click on browser back button i want to miantain all data enter by user on quote1 and want to assign to appropirate control
please help me
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: Maintain values on Browser Back button
Jan 02, 2013 02:34 AM|LINK
On your ScriptManager, you need to set EnableHistory="true". Then, on the buttons that change from page1 to page 2 (to print page #3), you have to invoke ScriptManager.GetCurrent(Page).AddHistoryPoint("KeyName", value);
This saves the back button history state.
Now you have to override the OnNavigate event of the ScriptManager (or ScriptManagerProxy if your ScriptManager is in a MasterPage). When navigating, you have to restore the user's previous state manually.
The default behavior of the back button is what you are seeing -- it goes to the previous URL loaded in the browser. When you are using UpdatePanels, this URL doesn't change.
There are a few tutorials about this, here is one: http://geekswithblogs.net/ranganh/archive/2008/11/17/enabling-the-browserrsquos-back-button-for-grid-view-asp.net-ajax.aspx
You can also google against ScriptManager, EnableHistory, AddHistoryPoint, and OnNavigate.
since the SP1 update for .NET 3.5 you have the History control for AJAX. This was specifically crafted for this task:Introduction to ASP.NET AJAX History.
http://quickstarts.asp.net/Futures/ajax/doc/history.aspx
http://weblogs.asp.net/brijmohan/archive/2008/09/11/using-asp-net-3-5-history-control-with-asp-net-2-0.aspx
http://www.nikhilk.net/BackButtonSupport.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Nikhil86
Member
70 Points
65 Posts
Re: Maintain values on Browser Back button
Jan 02, 2013 03:35 AM|LINK
Thanks a lot for reply.
Is there any way we can force the page to load from server and not from cache when user click on back button.
Nikhil86
Member
70 Points
65 Posts
Re: Maintain values on Browser Back button
Jan 02, 2013 03:36 AM|LINK
Also i have checked the post provided by you it will used for only 1 or 2 control.
but on my page i have 50-80 control how i can achive that do i need to add indidual control to view state.
Thanks
sukanta
Member
459 Points
130 Posts
Re: Maintain values on Browser Back button
Jan 02, 2013 04:57 AM|LINK
hi...
u can do this stuff using VIEW STATE.... use this statemanagement techniq for solve the issue
eg
http://asp-net-example.blogspot.in/2009/01/aspnet-viewstate-example-how-to-use.html
thanks....
priyankab
Member
2 Points
25 Posts
Re: Maintain values on Browser Back button
Jan 02, 2013 11:41 AM|LINK
Is it possible to maintain data without server postback?
I mean i started with Quote1 page >> Quote 2 .
Filled all data on Quote 2 page then pressed browser back button edited some data on quote 1 & then come back to quote 2....
So Can we maintain all data i entered previously.??
Nikhil86
Member
70 Points
65 Posts
Re: Maintain values on Browser Back button
Jan 05, 2013 05:10 AM|LINK
Hello Friend
Any help the above solution is not work for me
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
// HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
// HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
// HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
// HttpContext.Current.Response.Cache.SetNoStore();
line if code has been written on page load event even though page is not loding from its says page expiry message.
do i need to call this code in some other page event like page init or somehting please help me soon.
Niks
MahadTECH
Star
8976 Points
1659 Posts
Re: Maintain values on Browser Back button
Jan 05, 2013 06:44 AM|LINK
Use HTML5 SessionStorage.. It will Save your Values of TextBoxes till the Browser Close.
I'm coding for your requirements..
<!DOCTYPE html> <html> <head> <script> function SubmitForm() { var YourTextBox1 = document.getElementById("TextBox1").value; sessionStorage.setItem("Name", YourTextBox1); } function GetValues() { var NameSession = sessionStorage.getItem("Name") if (NameSession != null) { document.getElementById("TextBox1").value = sessionStorage.getItem("Name"); } } window.addEventListener("load", GetValues, false); </script> </head> <body onload="GetValues()"> <input type="text" id="TextBox1" /> <input type="button" onclick="SubmitForm()" value="Submit Form.." /> </body> </html>Note:
I'm preferring your to use HTML5 because its a new and useful technology.. so, hands on on HTML5...
Good Luck`
Mahad Bin Mukhtar
Remember to Mark the replies as Answers
The easiest day was 'yesterday'.
MCP, MCSD
For .NET TECH Blog
geniusvishal
Star
13984 Points
2783 Posts
Re: Maintain values on Browser Back button
Jan 05, 2013 06:57 AM|LINK
I recommend you to go through this article:
http://msdn.microsoft.com/en-us/magazine/cc300437.aspx
My Website
www.dotnetvishal.com
Nikhil86
Member
70 Points
65 Posts
Re: Maintain values on Browser Back button
Jan 05, 2013 12:45 PM|LINK
Hello ,
MY application is all reay build and i cant go with html 5 now
Please recomment something else
thanks