We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

ViewState with AJAX in ASP.NET

milani_lucie
milani_lucie asked
on
Medium Priority
707 Views
Last Modified: 2012-05-07
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
Comment
Watch Question

Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
Session is persisted.

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

Looks like the viewstate is not persisted.  How bout a cookie instead?
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
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.

Commented:
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.
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.