dlarlick
asked on
Refresh Vs Postback with Dynamic Controls
I am looking for an explanation of the difference between a postback and a refresh.
Please a little bit more than the obvious...
I am looking to solve the following error that I am receiving.
[HttpException (0x80004005): 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.
I have closely followed several examples about the whidbey project and several other dynmic control examples.
The site for the most part is menu driven with a single page that differring ascx controls are loaded into the body of the page depending on the user selection.
There are several controls that have a jump to another control. Essentially removing themselves from the placeholder on the form and replacing with the next control. This is used for a more fluid transition when values are passed from one screen to another. Works well .... until someone does a refresh right after the jump. Performing a postback then a refresh does not incurr the same error and completes successfully.
I have played with viewstate values but have not been able to terminate the problem.
I would like to start with a discussion on the difference between the refresh and the postback if possible.
I can post example code at a later time.
ASKER
On a refresh, how is the viewstate traversed,
Essentially... Why would I receive a different behavior from the server than if I had done a postback.
can you expand a little on the exact page life cycle differences...
Thanks for the response.
Hi dlarlick,
check this thread ( for your error ) : https://www.experts-exchange.com/questions/20944710/Failed-to-load-viewstate-Bug.html
Regards!
B..M
mmarinov
check this thread ( for your error ) : https://www.experts-exchange.com/questions/20944710/Failed-to-load-viewstate-Bug.html
Regards!
B..M
mmarinov
ASKER
mmm not sure......
don't have a datagrid and only happens on the initial refresh of a page after a new control is swapped into the body.
I'm rebuilding the controls and should match the viewstate, I'm baffled why I would error on an initial refresh and not a submit, subsequent refreshes are fine.
ASKER
I found a qoute from Gary McGlennon, from Visual Studio Magazine, but still am unsure how it may apply to my circumstance as I am reassigning the id of the controls I add to the form. (unless.. the control id's on the control are affected hmmm...)
Well any way... Hope this adds to the direction of my intended discussion.
"The control state works correctly only on every second postback. I'll discuss the reasons why.. " (regarding dynamic controls)
"The internal counter keeps increasing when you add a usercontrol, but doesn't decreae if you remove one, until it's re-created on postback."
http://www.ftponline.com/vsm/2003%5F04/magazine/columns/aspnet/
ASKER
Please remove topic and refund points. PAQ
No additional knownledge was gained from this thread.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A postback is when a form on the page is posted to the server, and uses the POST method. The server can then interpret any inputs that were on the form.
When you check Page.IsPostBack, you are asking, "Did the user press a submit button?", or if you have controls set to AutoPostBack, they will post when they are selected (radios, checkboxes, listboxes are onchange).