views:

1460

answers:

4

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.

A: 

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.

Rex M
A: 

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.

Peanut
This should be a comment under the answer or added as clarification to your question.
Rex M
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
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.
StriplingWarrior
+2  A: 

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.

BPAndrew
A: 

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.

http://stackoverflow.com/questions/271269/ideas-for-how-to-deal-with-viewstate-when-using-asp-net-ajax-and-update-panels

Middletone