AJAX vs. ViewState?

A

Arthur Dent

Hello all...

Quick Q... I have a page which on load, retrieves some data from the db, and
then stores it in the viewstate. It is a small snippet of XML.
I have some controls on the page which post back via AJAX; in their
handlers, the page attempts to refer to this XML from the viewstate (to
minimize roundtrips to the db server).
It seems though that when they post back, this information (the XML) is
gone.

Do AJAX postbacks not have access to what was stored in the viewstate?
Looking online, I see a lot of people questioning about this, but no
definitive answers.

Thanks in advance,
- Arthur Dent.
 
C

Cowboy \(Gregory A. Beamer\)

ViewState is a hidden field in the page that is encoded. Unless you send
that information back to the server in your AJAX call, it will never be
available, as the server does not store ViewState. If, instead, you store
items in session, you can pull them, but I would not retool a site to stick
everything in session just so you can use it with AJAX.

As each field on the page is accessible, you can send as much info as you
like. This will generally be better than wiring the ViewState to AJAX.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top