[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 690
  • Last Modified:

ViewState with AJAX in ASP.NET

Hi,

I have a page with AJAX enabled. I want to store some information on server side in the ViewState object as

ViewState("Key") = Value

Does this persists between the postbacks - because page is a partial rendering ? If it is not going to be persisted between the postbacks then what i need to do to get the value from ViewState ?

Thanks
0
milani_lucie
Asked:
milani_lucie
  • 3
  • 2
2 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
Does it need to be in the viewstate or can you store it in the session?

Session("key") = value
0
 
milani_lucieAuthor Commented:
ged325:

Needs to be in ViewState. I do not want the Session overhead on the server. BTW: Is Session is going to be persisted between the postbacks ?

Thanks
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
Session is persisted.

http://helpcentral.componentone.com/CS/forums/t/74987.aspx

Looks like the viewstate is not persisted.  How bout a cookie instead?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Kyle AbrahamsSenior .Net DeveloperCommented:
http://blog.js-development.com/2009/02/howto-persist-viewstate-on-server-side.html

A temporary solution to persist the viewstate, but still you're going to have the server doing the work.
0
 
NazoUKCommented:
If you're using updatepanels then the ViewState is persisted. The ViewState is passed back to the server when an ajax call is made and then passed back to the page.
In other words you can use ViewState as normal on a page with updatepanels but you should do so with caution: a large ViewState can slow the updatepanels to a crawl and make for a very frustrating user experience.
0
 
NazoUKCommented:
As an aside, the page ged325 linked to is talking about Client Callbacks which is not the same as the partial rendering achieved through ASP.NET AJAX and UpdatePanels.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now