AJAX vs. ViewState?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arthur Dent

    AJAX vs. ViewState?

    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.

  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: AJAX vs. ViewState?

    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


    or just read it:


    *************** *************** *************** ****
    | Think outside the box!
    |
    *************** *************** *************** ****
    "Arthur Dent" <hitchhikersgui deto-news@yahoo.comw rote in message
    news:58FBA8A3-7AB4-4306-B9EA-0E365F7F702E@mi crosoft.com...
    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.

    Comment

    Working...