One may need to provide a confirmation dialog to the users and initiate an AJAX request if accepted. Confirmation using standard post backs often looks like this:
| ASPX |
Copy Code |
|
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="return confirm('Are you sure?');" /> |
The OnClientClick should be changed a bit to work with AJAX:
| ASPX |
Copy Code |
|
<asp:ImageButton ID="ImageButton2" runat="server" OnClientClick="if (!confirm('Are you sure?')) return false;" /> |
when the button is ajaxified by added the necessary AJAX setting to RadAjaxManager or when the button is placed within RadAjaxPanel control.
Alternatively, the OnRequestStart client-side event could be used to implement more complex logic. Here is a sample script:
| JavaScript |
Copy Code |
|
<script type='text/javascript'> function OnRequestStart(ajaxControl, eventArgs) { var eventTarget = eventArgs.EventTarget; if (eventTarget == "<%= ImageButton1.UniqueID %>") { return confirm( } else { return false; } } |
You can review the Cancellation of AJAX requests online demo, where this approach is followed.
See Also