AJAX vs. ViewState?

  • Thread starter Thread starter Arthur Dent
  • Start date Start date
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.
 
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.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
 
Back
Top