?
Solved

Refresh Vs Postback with Dynamic Controls

Posted on 2004-11-08
8
Medium Priority
?
393 Views
Last Modified: 2008-02-01

  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.
 
0
Comment
Question by:dlarlick
7 Comments
 
LVL 5

Expert Comment

by:jpontani
ID: 12527016
A refresh is when the page is loaded as an request, and uses the GET method. (such as when the page is first loaded by the user).
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).
0
 
LVL 2

Author Comment

by:dlarlick
ID: 12527181

  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.

 
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12527201
Hi dlarlick,

check this thread ( for your error ) : http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20944710.html


Regards!
B..M
mmarinov
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:dlarlick
ID: 12527504

  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.



   
0
 
LVL 2

Author Comment

by:dlarlick
ID: 12560534


  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/
 
 
0
 
LVL 2

Author Comment

by:dlarlick
ID: 12596604

  Please remove topic and refund points. PAQ
 
  No additional knownledge was gained from this thread.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12828126
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question