Monday, March 26, 2012

Previous ViewState being used after UpdatePanel refresh

I am not sure its a problem with a viewstate--just a guess. The problem is this:

I have a page that uses a master page. It has two updatepanels in it. One updatepanel has a dropdownlist and one has a button and a label. When the button triggers a partial postback, I set the value of the label and can see it change on the page. When the dropdownlist triggers a partial postback the label switches back to its previous value right before the partial postback. When I inspect the value in the code behind for the dropdownlist the previous value is what is in the label.

What could be causing this? Has someone else had a similar problem? Where was the previous value even stored for it to be retrieved. Does each updatepanel have a viewstate?

Due to the complexity of my master page, I cannot put the dropdownlist, button and label in the same updatepanel. Is that the source of the problem?


There's one ViewState for the entire page, and it's updated during each async postback.

Could you boil this down to a small sample (e.g. a couple UpdatePanels, one with a DropDownList, one with a Label) and paste the code here?

Also, try removing the UpdatePanels (or setting EnablePartialRendering="false" on your ScriptManager) to see if this works with regular postbacks. That may help to figure out what's going wrong.


Also make sure each UpdatePanel's UpdateMode is set to conditional.

No comments:

Post a Comment