views:

9

answers:

1

In a nutshell:

Whenever a postback would occur (AJAX'ed by an UpdatePanel) I want to do a callback beforehand and only after the callback has completed (either successfully or not) should the postback occur. How can I do this?

Elaborate explanation:

We use ASP.NET AJAX (UpdatePanel 'n stuff) together with DevExpress controls. Among those controls is the ubiquitous GridView. As is typical with ASP.NET gridviews, you can edit rows one-by-one, and to save your changes you have to hit the "update" button at the end of the row. However if you make some changes to the row, then forget to press the "update" button, and hit something else in the page (say the big red SAVE button that causes a postback and saves the whole form to the DB), your changes will be lost. The row will still be in edit mode, but it will have reset to the data it had initially when you started the edit.

Our clients are not happy with this and want the row to be saved automatically if the user forgets to do so himself.

Luckily the DevExpress gridview is smart enough to have an "Update()" method which I can call from JavaScript. Unluckily that causes a callback and returns immediately. If I allow the postback to continue as normally, the callback will get aborted. Well, technically it's a race condition I guess, but so far it seems that the postback wins. There are events to which I could attach for success/failure of the callback, but I don't know how to "resume" the postback that started it all.

We could turn off callbacks for all the grids, but that would be a performance disaster.

Any ideas?

A: 

Use the DevExpress GridViews modal popup window for editing. That way they can't press anything else to trigger the postback until the editing is finished.

or

The ASPxGridView has a clientside method IsEditing(). Check this value when the 'big red SAVE button' is clicked and prevent the postback or show a message if the grid is in edit mode.

geoff
I'll give it a try, but I suspect it would become very inconvenient if every grid in the system started doing this. Currently we are using inline editing mode almost exclusively.
Vilx-
@Vilx - You could manually disable the other controls using javascript when the grid enters edit mode and re-enable when editing ends. Or check whether the grid is in edit mode when the save button is pressed and prevent the postback if it is.
geoff
Hmm... the preventing is a good idea, perhaps coupled with a message!
Vilx-
@Vilx - Answer updated
geoff