This is a migrated thread and some comments may be shown as answers.

confirm before event

2 Answers 66 Views
Button
This is a migrated thread and some comments may be shown as answers.
Petar
Top achievements
Rank 1
Petar asked on 16 May 2013, 10:28 AM
Hi

Is there any posibility that user confirm his action before onclick method start
somethin like this

<telerik:RadButton ID="btnEdit" runat="server" OnClientClicked="ConfirmEdit" OnClick="btnEdit_Click"></telerik:RadButton>

So, I would like that in JS user confirm his action in ConfirmEdit method and after that if he clicked on 'OK' to call btnEdit_Click method on server side

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 May 2013, 11:30 AM
Hi Petar,

You can attach the OnClientClicking client event instead of OnClientClicked to cancel the server-side click based on the Confirm result. Please have a look at the following code I tried which works fine as expected.

ASPX:
<telerik:RadButton ID="btnEdit" runat="server" Text="Edit" OnClientClicking="ConfirmEdit" OnClick="btnEdit_Click">
</telerik:RadButton>

JavaScript:
<script type="text/javascript">
    function ConfirmEdit(sender, args) {
        args.set_cancel(!confirm("Are you sure you want to edit?"));
    }
</script>

Thanks,
Shinu.
0
Petar
Top achievements
Rank 1
answered on 16 May 2013, 12:45 PM
It work's fine

Thanks.
Tags
Button
Asked by
Petar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Petar
Top achievements
Rank 1
Share this question
or