1

Is there a way to stop the processing of a callback initiated by a custom button defined in an ASPxGridView grid?

I have this in my code:

BeginCallback="function(s, e) {
    var response = confirm('Really want to do this?');
    //if response = false, I need to stop processing...
}"

I need one of two solutions:

  1. stop immediately the call (the server will not be hit) or
  2. inform the server that the call was cancelled so that the server can just exit quickly from callback handler.

Thanks.

Adi
  • 5,113
  • 6
  • 46
  • 59

3 Answers3

3

You can do this..

<ClientSideEvents CustomButtonClick="function(s, e)
{
if(e.buttonID=='Send')
{
if (confirm ('Are you sure?'))
{
e.processOnServer = true;
}
}
else
{
e.processOnServer = true;
}
}
" />

Credit

2

You can't cancel callback in BeginCallback event handler. You should try to display confirmation dialog before callback starts. I'm sure you don't want to add confirmation dialog to all grid callbacks (paging, sorting, grouping, editing, custom callbacks etc).
Look here for offical explanation.

Filip
  • 3,257
  • 2
  • 22
  • 38
0

You cannot Cancel the callback in the BeginCallback Event. You could do something like this as an alternate solution.

<dxe:ASPxButton ID="btnConfirm" runat="server" AutoPostBack="False" Text="Callback">
    <ClientSideEvents Click="function(s, e) {if(!confirm('Really want to do this?')) return; gvCallbackGrid.PerformCallback();}" />
</dxe:ASPxButton>

<dxwgv:ASPxGridView ID="gvCallbackGrid" runat="server" ClientInstanceName="gvCallbackGrid">
....
</dxwgv:ASPxGridViewTemplateReplacement>
Akhil
  • 7,570
  • 1
  • 24
  • 23