Confirm Dialog not showing up

5 posts, 1 answers
  1. Emir Prcic
    Emir Prcic avatar
    19 posts
    Member since:
    Dec 2009

    Posted 06 Jun 2011 Link to this post

    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.
  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 06 Jun 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Emir Prcic
    Emir Prcic avatar
    19 posts
    Member since:
    Dec 2009

    Posted 06 Jun 2011 Link to this post

    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

  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 06 Jun 2011 Link to this post

    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.

  6. Manish
    Manish avatar
    1 posts
    Member since:
    Jun 2013

    Posted 02 Jun 2013 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017