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

Confirm Dialog not showing up

4 Answers 237 Views
Button
This is a migrated thread and some comments may be shown as answers.
Emir Prcic
Top achievements
Rank 1
Emir Prcic asked on 06 Jun 2011, 07:43 AM
Hy,
I am having troubles to get a Radbutton working together with a javascript confirm dialog. The intention is, to show the confirm dialog prior to executing the delete command (which the radbutton represents). However, altough I am using the same Code, I already found in this forum, the button simply creates the postback, without even showing the dialog. The Code i use is:

<telerik:RadButton ID="BtnDelete" runat="server" OnClientClick="javascript:if(!confirm('This action will delete the selected customer. Are you sure?')){return false;}" Skin="Outlook" Text="Löschen" onclick="BtnDelete_Click">
</telerik:RadButton>

For testing purposes, I tried a default Button, which works without any troubles:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return confirm('Are you sure to Continue?');" />

Does anybody have any suggestions what to do?

If it is from interest:
I am using the Controls in a Webpart for a Sharepoint 2010 environment.

4 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 06 Jun 2011, 08:04 AM
Hi Emir,

I believe the following demo will help you achieve the desired scenario: http://demos.telerik.com/aspnet-ajax/button/examples/confirm/defaultcs.aspx.

All the best,
Pero
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Emir Prcic
Top achievements
Rank 1
answered on 06 Jun 2011, 08:07 AM
I think I somehow found the solution

As shown here, it seems that I have to use the "OnClientClicking" event, together with defining the javascript as function in the <scripts> Section.

So this configuration of the radbutton

<telerik:RadButton ID="BtnDelete" runat="server" OnClientClicking="DeleteConfirm" Skin="Outlook" Text="Löschen" onclick="BtnDelete_Click">

together with the corresponding function

function DeleteConfirm(sender, args) {
    args.set_cancel(!window.confirm("Are you sure you want to delete the entry?"));
}

works!.

However, I usually like to know why. (using my former Javascript-Code in the "OnClientClicking"-event does not work). Im quite happy to have it working now, but if anybody is able to give me a short explanation, why I it did not work in the OnClientClick Event or without using a defined function,  that would be very appreciated.

Have a nice day

0
Pero
Telerik team
answered on 06 Jun 2011, 09:41 AM
Hello Emir,

The Ajax controls (all of our controls from the RadControls for ASP.NET Ajax suite) expect an object of type function for their client-side events. That's why we set only the name of the function (without the parentheses)
to the RadButton.OnClientClicking property. You could also set an anonymous function in the following way:
<telerik:RadButton ID="BtnDelete" runat="server"
 OnClientClicking="function (sender, args){args.set_cancel(!window.confirm('Are you sure?'));}"
 Text="Löschen">
</telerik:RadButton>

Regards,
Pero
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Manish
Top achievements
Rank 1
answered on 03 Jun 2013, 04:35 AM
Hi,

I did try with the given solution ( RadConfirm). I need it to show confirmation message after validation like RequiredField and some other. 
I search on the forum and many solutions are there but I was not able to do it correct way.

I did try with following from a different thread: 
var validated = Page_ClientValidate();
if (validated)
{
// Rad Confirm Code here.... 
}

It validates the form first, I have validation summary control on my form and now it is showing validation messages box twice.

*** To avoid this I set CausesValidation property to "false" of RadButton.

Now It works fine to me ...

Regards
Manish
Tags
Button
Asked by
Emir Prcic
Top achievements
Rank 1
Answers by
Pero
Telerik team
Emir Prcic
Top achievements
Rank 1
Manish
Top achievements
Rank 1
Share this question
or