KellyLynch
KellyLynch

Reputation: 251

AspxClientPopupControl: CloseButtonClick and ValueChanged

I am using DevExpress v10. I have an ASP.NET page with AspxPopupControl. The AspxPopupControl contains several textboxes AspxTextBox.

I need the following functionality: when user clicks Close button in header of the AspxPopupControl popup, to check if something has been changed in the AspxTextBox fields since the popup was opened. If it has, a confirmation 'do you really want to close the window without saving?'

I intended to implement it as the following: to handle client-side event ValueChanged for the AspxClientTextBox controls. In such handler I could set a flag, and later analyze it in client-side handler of Closing event (AspxClientPopupControl)

But the problem is: if I change something in an AspxTextBox and then click the Close button immediately, Closing event will be fired FIRST and ValueChanged event will be fired AFTER Closing!

This does not allow me to do what I want.

Is any solution possible here?

Upvotes: 0

Views: 4406

Answers (1)

Joao
Joao

Reputation: 7486

The Closing event receives as an argument an ASPxClientPopupWindowCancelEventArgs which you can use to cancel the closing event.

You can do something along this lines:

<dx:ASPxPopupcontrol>
    ...
    <ClientSideEvents Closing="popup_Closing" />
</dx:ASPxPopupControl>

<script type="text/javascript">

    function popup_Closing(s,e)
    {
        if (textbox1.GetText() == '' || ...) // or logic here
        {
            e.cancel = !confirm('You've empty fields. Continue anyway?');
        }
    }

</script>

Upvotes: 1

Related Questions