0

I've a page that has a series of web controls. One of these is a textbox with AutoPostBack turned off.

The way the page operates is that a button is clicked to save the form data. This button sits outside of the updatepanel.

So when I hit the save button the partial postback happens for the dropdownlist and after this postback has completed a full postback fires for the save button. However when the full postback fires the form data is returned to the state before the save button was clicked - i.e. my changes are removed.

I believe this could be to do with the viewstate being returned from the partial update and that viewstate not updating in the page before the full postback fires - or it getting corrupted.

Does anyone have any ideas?

Thanks.

4 Answers 4

4

Don't mean to sound negative but these scenarios are what made me give up "by the book" ASP.net AJAX. Learning jQuery /w simplistic ASP.net forms /w NO postbacks has lead me to build more useful and cooler UI experiences than what I had to battle to get working with update panels etc.

0

If you set UpdateMode="Conditional" and ChildrenAsTriggers="true" on your UpdatePanel, that will ensure the partial postback only executes when the DropDownList's postback event fires, not when the Button is clicked.

0

Thanks for the quick response! However I need the save buttons click event to fire too. The order in which the events fire is perfect:

  1. dropdownlist changed event (partial)
  2. save button click event (full)

The problem is the loss of form data after the partial postback.

Many thanks.

3
  • This should be a comment under the answer or added as clarification to your question.
    – Rex M
    Feb 5, 2009 at 15:55
  • I didn't realise there were "rules". Surely it's down to the user to represent themselves in the way they see fit. I've seen plenty of examples of users who have replied via 'answers'. I makes there response more visible. Grump aside - I do appreciate your help.
    – Peanut
    Feb 5, 2009 at 16:20
  • While you're free to do whatever you want, there are actually some good reasons why it's better not to respond with answers. For one thing, there is no guarantee that people looking at this page in the future will see the answers in the order in which they were given. Some people sort by the number of votes, for example. Oct 28, 2009 at 22:40
0

I've already posted a solution to this on another post. This simple code will ensure that your viewstate works with both the postback and partial postback.

Ideas for how to deal with viewstate when using ASP.NET AJAX and update panels

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.