Monday, March 26, 2012

Maintain state between 2 pages.

I have an application which consists of 2 web forms. On the first
page I have a datagrid with paging and sorting turned on. I also have a
textbox which allows me to filter the data in the grid and narrow down
the results. The grid also contains a column with hyperlinks which when
clicked should invoke the second page which displays details about the
current row.

I call the second page with Server.Transfer("second.aspx"). On this
page I have a button which allows me to navigate back to the first
page.

My question is the following: Is there an easy way to maintain the
state of the first page (sort direction - asc., desc., sort column,
filter text, current page of the datagrid) during the trip to the
second page and be able to reconstruct it the way I left it or should I
use the Session object to store all the information?

This could be a common issue when implementing web *wizards* with
next> and <previous buttons. How to maintain page state in such a
scenario?

Any suggestions are welcome. Thanks in advance.You will probably need to use Session State. However, if your hyperlink opens
the second page in a new browser window instead of using Server.Transfer, you
won't need to, since the first page will still be open.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"darin_dimitrov@.hotmail.com" wrote:

> I have an application which consists of 2 web forms. On the first
> page I have a datagrid with paging and sorting turned on. I also have a
> textbox which allows me to filter the data in the grid and narrow down
> the results. The grid also contains a column with hyperlinks which when
> clicked should invoke the second page which displays details about the
> current row.
> I call the second page with Server.Transfer("second.aspx"). On this
> page I have a button which allows me to navigate back to the first
> page.
> My question is the following: Is there an easy way to maintain the
> state of the first page (sort direction - asc., desc., sort column,
> filter text, current page of the datagrid) during the trip to the
> second page and be able to reconstruct it the way I left it or should I
> use the Session object to store all the information?
> This could be a common issue when implementing web *wizards* with
> next> and <previous buttons. How to maintain page state in such a
> scenario?
> Any suggestions are welcome. Thanks in advance.
>

0 comments:

Post a Comment