Formview delete confirmation

3 posts, 1 answers
  1. Lee
    Lee avatar
    16 posts
    Member since:
    Dec 2010

    Posted 20 Jan 2011 Link to this post

    The radbutton does not support the onclientclick property as outlined below:

    <asp:Button ID="Button1" runat="server" CausesValidation="False" 
         CommandName="Delete" Text="Delete"                                    
         OnClientClick="return confirm('Are you certain you want to delete this Customer?')" 
         BackColor="#3333CC" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" 
         ForeColor="White" />
     <telerik:RadButton ID="RadButton6" runat="server" CausesValidation="False" 
         CommandName="Delete" Text="Delete" Skin="Web20"
         OnClientClick="return confirm('Are you certain you want to delete this Customer?')">
    </telerik:RadButton>

    The ASP button will present a delete confirmation in a formview. The telerik button will not. Is there a way to get this to work with the Telerik button?

    Regards, Lee
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2011 Link to this post

    Hello Lee,

    The OnClientClicked property of the RadButton control expects the name of the javascript function that will handle the clicked client-side event.
    Here is the sample code to achieve the your scenario.

    aspx:
    <telerik:RadButton ID="RadButton6" runat="server" CausesValidation="False" CommandName="Delete"
                Text="Delete" Skin="Web20" OnClientClicked="OnClientClicked">
    </telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
    function OnClientClicked(button, args)
            {
                if (confirm('Are you certain you want to delete this Customer?'))
                {
                    button.set_autoPostBack(true);
                }
                else
                {
                    button.set_autoPostBack(false);
                }
            }
    </script>

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lee
    Lee avatar
    16 posts
    Member since:
    Dec 2010

    Posted 21 Jan 2011 Link to this post

    Thanks Shinu,

    It works fine.

    Regards, Lee


Back to Top