Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2013, 12:33 AM
Authorized User
 
Join Date: Aug 2012
Posts: 39
Thanks: 4
Thanked 1 Time in 1 Post
Default Page Navigation - Go back to previous page

Fellow readers and/or author, please help!

Question:
How do you programmatically redirect your browser back to the previous page - equivalent to the IE back button! ? Over 8 hours searching for such a simple task, it's getting demoralizing.

Context:
I have a Gridview which consumes a SqlDataSource using SelectParameters-ControlParameters. These parameters are used to build a sql query off of a SQL View. They are selectable by the user from dropdown lists above the gridview (just like examples from the book). So, when the user is looking at a "filtered" dataset (the sql view with WHERE clause parameters), they are able to click a row to see the details of that record. After viewing the details of a row, HOW DO I GO BACK TO THAT FILTERED GRIDVIEW WITHOUT CHANGING A THING?

What I have found:
To others who are looking for a solution to this, I have a partial answer. Considering a button that you click to cancel/exit/go back, you can set this button property which works perfectly well if that's all you want to do: PostBackUrl="javascript:history.go(-1);"

This will take you back to your filtered list with all inputs still in the page controls (as if nothing was posted to the server at all). However, if you want to add this functionality to the end of the button_click event handler, you will find few or no solutions on the web. Clearly, I am missing some fundamental knowledge about how the system works because it seems to me that there shouldn't be a whole lot of things easier to do than this. The browser itself has it built into the back button!!!

I would appreciate any and all feedback on this.

Thank you.
WebDev123
 
Old January 18th, 2013, 06:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Since this is not directly related to my book, please post questions like these in a general ASP.NET category: http://p2p.wrox.com/asp-net-4-539/

That said: yes, this is a common issue. The browser's back button takes you to the previous page; you can accomplish this client side using history.go(-1) which you can also trigger from the server side by adding that code in a script block on a literal control which gets rendered after a postback.

Other solutions:

1. "Forward" to the previous page. In other words, render a new page that mimics the previous state, but setting up stuff like filters, current page etc. This requires some coding as you need to keep track of state.

2. Look into History controls such as this one: http://www.asp.net/web-forms/videos/...istory-control

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
From a page, call another, get some data, pass it back to first page alharlow ASP.NET 4 General Discussion 5 April 25th, 2011 10:58 AM
How to expire previous page johnsonlim026 ASP.NET 1.0 and 1.1 Basics 6 May 22nd, 2009 12:05 PM
Login page back to original page pablohoney Classic ASP Basics 1 October 3rd, 2006 07:09 PM
next and previous page results mikeuk PHP Databases 1 July 19th, 2004 05:15 AM
go back previous page hosefo81 PHP How-To 2 February 11th, 2004 01:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.