Failed to load viewstate (i.e., I'm doomed).

Discussion in 'ASP .Net' started by Mike Hnatt, Nov 3, 2003.

  1. Mike Hnatt

    Mike Hnatt Guest

    I normally try to post more helpful subject lines. But in this case, after
    tons of development, my app suddenly works no more.
    Here is the message: I get this on the page postback when it dynamically
    builds the controls based on the value I select in a drop-down list. It is
    inconsistent. Sometimes the exact same process works, and sometimes it
    doesn't. BTW, my drop-down list determines the control layout.
    Any help would be majorly appreciated.

    >>message below<<


    "Failed to load viewstate. The control tree into which viewstate is being
    loaded must match the control tree that was used to save viewstate during
    the previous request. For example, when adding controls dynamically, the
    controls added during a post-back must match the type and position of the
    controls added during the initial request. "
    Mike Hnatt, Nov 3, 2003
    #1
    1. Advertising

  2. Mike Hnatt

    Jos Guest

    Mike Hnatt wrote:
    > I normally try to post more helpful subject lines. But in this case,
    > after tons of development, my app suddenly works no more.
    > Here is the message: I get this on the page postback when it
    > dynamically builds the controls based on the value I select in a
    > drop-down list. It is inconsistent. Sometimes the exact same
    > process works, and sometimes it doesn't. BTW, my drop-down list
    > determines the control layout.
    > Any help would be majorly appreciated.
    >
    >>> message below<<

    >
    > "Failed to load viewstate. The control tree into which viewstate is
    > being loaded must match the control tree that was used to save
    > viewstate during the previous request. For example, when adding
    > controls dynamically, the controls added during a post-back must
    > match the type and position of the controls added during the initial
    > request. "


    On postback, you have to make sure that exactly the same dynamic
    controls are built (same name and number) as before the postback
    (preferably in Page_Load), EVEN IF YOU DON'T WANT THEM TO
    APPEAR ON YOUR PAGE ANYMORE.

    Only then the necessary control postback events can fire.

    In the handlers for these events, you can then rebuild your page
    by destroying any unwanted controls and by adding new ones.

    --

    Jos
    Jos, Nov 3, 2003
    #2
    1. Advertising

  3. Mike Hnatt

    Mike Hnatt Guest

    Thanks Jos,
    I will try that. I just can't seem to understand why it worked fine for
    hundreds of times until now. I'm sure it is something though. Thanks for
    the help!
    Mike

    "Jos" <> wrote in message
    news:...
    > Mike Hnatt wrote:
    > > I normally try to post more helpful subject lines. But in this case,
    > > after tons of development, my app suddenly works no more.
    > > Here is the message: I get this on the page postback when it
    > > dynamically builds the controls based on the value I select in a
    > > drop-down list. It is inconsistent. Sometimes the exact same
    > > process works, and sometimes it doesn't. BTW, my drop-down list
    > > determines the control layout.
    > > Any help would be majorly appreciated.
    > >
    > >>> message below<<

    > >
    > > "Failed to load viewstate. The control tree into which viewstate is
    > > being loaded must match the control tree that was used to save
    > > viewstate during the previous request. For example, when adding
    > > controls dynamically, the controls added during a post-back must
    > > match the type and position of the controls added during the initial
    > > request. "

    >
    > On postback, you have to make sure that exactly the same dynamic
    > controls are built (same name and number) as before the postback
    > (preferably in Page_Load), EVEN IF YOU DON'T WANT THEM TO
    > APPEAR ON YOUR PAGE ANYMORE.
    >
    > Only then the necessary control postback events can fire.
    >
    > In the handlers for these events, you can then rebuild your page
    > by destroying any unwanted controls and by adding new ones.
    >
    > --
    >
    > Jos
    >
    >
    Mike Hnatt, Nov 3, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavino
    Replies:
    1
    Views:
    341
    Philipp Leitner
    Jul 19, 2006
  2. sck10
    Replies:
    6
    Views:
    902
    sck10
    Sep 1, 2006
  3. Josema
    Replies:
    2
    Views:
    341
  4. Josema
    Replies:
    0
    Views:
    198
    Josema
    May 9, 2005
  5. David Mark

    YUI--doomed?

    David Mark, May 22, 2010, in forum: Javascript
    Replies:
    7
    Views:
    188
    David Mark
    May 24, 2010
Loading...

Share This Page