Edward Gracey
Edward Gracey

Reputation:

Persisting state of an asp.net page

Am new to asp.net

Here is what I need to do: I've an asp.net page called Results.aspx which has got 8 AJAX collapsible panels and a gridview control binded to database.It also has pagination functionality.

From this page, user can navigate to other pages in the application.When he comes back to Results.aspx,I need to persist states of the following areas: 1.All collapsible panels 2.Gridview control 3.Pagination

What is the most efficient way of achieving this in asp.net other then using asp.net sessions?

Upvotes: 1

Views: 256

Answers (3)

Andrew Hare
Andrew Hare

Reputation: 351516

ASP.NET Session is the most efficient way of doing this. You are harnessing a built-in, session-specific, user-specific state manager that is very fast and optimized to do exactly what you want to do. In this particular instance I would suggest that you store the metadata required to persist the user's settings in session (don't use session as a ViewState-replacement into which you cram whole controls). If you use session responsibly then I think you will find it suits your needs.

You could definitely do it other ways but why would you want to?

Upvotes: 1

John Saunders
John Saunders

Reputation: 161773

Using ASP.NET session state is about as efficient as you're going to get with this. You can use a custom session state provider if you feel the normal one is wrong for you, but it's pretty much the only way to persist the state of a page when you're on another page.

I suppose the other thing you could do is persist the state in a hidden field, then somehow post that to all the other pages you might possibly use after that.


The ASP.NET Cache object keeps information for the entire application - it is not per-user, so it would be a very bad way to persist per-page-per-user state.

Upvotes: 0

MRFerocius
MRFerocius

Reputation: 5629

Session State is the option, but beware how you implement that if you have a Server Farm or you are planning to escale your application.

Regards!!!

Upvotes: 0

Related Questions