locked
How to preserve entire page layout when returning back to the same page using Response.Redirect? RRS feed

  • Question

  • User246057125 posted

    I have a page with a GridView control. The GridView control has rows with "Edit" button. When user clicks this Edit button, another page is loaded. This new page itself has a button to return to the previous page i.e, the page which contains the GridView control.

    The problem is that when I return to the GridView page, I get a fresh new look. Instead, I want the same look where the user left the page.

    Is there any way to preserve the entire page layout and retrieve when returned?

    Sunday, October 14, 2012 12:15 PM

Answers

  • User1779161005 posted

    Well, my point was that whatever state you need to remember needs to be passed along to the next page and then returned back to the original page. If the request from page to page are GET requests then the obvious place to pass that state is in the query string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 14, 2012 12:54 PM

All replies

  • User1779161005 posted

    Pass a flag (via query string, perhaps) when the user hits the "edit" button. Then once  on the edit page and they hit the "return" button pass the flag back to the original page. The original page would then use the flag to know what state to put itself back into.

    This is all just standard state management when building web apps :)

    Sunday, October 14, 2012 12:21 PM
  • User246057125 posted

    A flag is not possible because I have several controls on the Page. It is is not possible to store each control's history independently?

    Sunday, October 14, 2012 12:26 PM
  • User1779161005 posted

    Well, my point was that whatever state you need to remember needs to be passed along to the next page and then returned back to the original page. If the request from page to page are GET requests then the obvious place to pass that state is in the query string.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 14, 2012 12:54 PM
  • User246057125 posted

    Can I store entire GridView in View State?

    Sunday, October 14, 2012 11:41 PM
  • User1779161005 posted

    Chances are that the grid view is already doing this.

    Sunday, October 14, 2012 11:53 PM
  • User-735357247 posted

    Since Asp.net is stateless it cannot remember the information of previous pages. Every time when you hit the page it will load fresh data.

    Even storing the gridview in view state does n't help - The reason being view state can be persisted only for the current page. If the page is redirected to some other then view state values will be lost.

    In your case you need to store the row ids or primary key values in session before redirecting to another page when edit button is clicked and when you are loading back the original page, read the values from session and based on your row ids or primary key values reload the grid.

    Monday, October 15, 2012 6:19 AM