RadButton in RadGrid not firing

Thread is closed for posting
4 posts, 0 answers
  1. Rick
    Rick avatar
    33 posts
    Member since:
    Aug 2012

    Posted 16 Jan 2012 Link to this post

    I have a radButton in the groupfooter of a radGrid.  

    I have set the OnClick to call the button click which is in ASP.  It is a delete button, so I wanted to confirm deletion before actually deleting.  The OnClientClicked does not fire.  For testing purposes, I even removed the OnClientClick  andOnClientClicked still does not fire.  Here is a snippet of my code:

    <GroupFooterTemplate>
        <telerik:RadButton runat="server" ID="RadButton1" Text='<%# sDeleteButtonText %>' Value='<%# sCountryCode %>' OnClientClicked="if(!confirm('Are you sure you want delete this?')) return false;" >
        </telerik:RadButton>
    </GroupFooterTemplate>

    The OnClientClick, when it was in there, would go to this code:
    Public Sub RadButton1_click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim button As RadButton = sender
        SqlDataSource1.DeleteParameters.Item("CurrencyTarget_CountryCode").DefaultValue = button.Value
        SqlDataSource1.Delete()
        RadGrid1.MasterTableView.Rebind()
        RadGrid1.CurrentPageIndex = 0
    End Sub


    I am on Windows 7
    I am using MS Visual Studio 2010
    I have the latest RadControls v.2011.3.1305.35
  2. Rick
    Rick avatar
    33 posts
    Member since:
    Aug 2012

    Posted 17 Jan 2012 Link to this post

    PS - If there is any additional information you need in order to reply and help, please let me know.
  3. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 17 Jan 2012 Link to this post

    Rick:

    The OnClientClicked property of the RadButton control expects the name of the javascript function that will handle the clicked client-side event. Please visit our online demo showing the client events of the RadButton control: http://demos.telerik.com/aspnet-ajax/button/examples/clientsideevents/defaultcs.aspx.

    Here is how you can achieve your specific scenario...

    Default.aspx:
    <%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="RadButton_ClientEvents._Default" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            function OnClientClicked(button, args) {
                if (!window.confirm("Are you sure you want delete this?")) {
                    button.set_autoPostBack(false);
                }
                else {
                    button.set_autoPostBack(true);
                }
            }
      
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>
        <telerik:RadButton runat="server" ID="RadButton1" Text="Delete" Value="Country1" OnClientClicked="OnClientClicked">
        </telerik:RadButton>
        </div>
        </form>
    </body>
    </html>

    Default.aspx.vb:
    Imports Telerik.Web.UI
     
    Partial Class _Default
        Inherits System.Web.UI.Page
     
        Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles RadButton1.Click
            Page.Response.Write("RadButton1_Click Fired!")
        End Sub
    End Class
     
    See the screenshots attached: "radbutton_onclientclicked_fired.png" and "radbutton_onclick_fired.png".

    Cheers!
  4. Rick
    Rick avatar
    33 posts
    Member since:
    Aug 2012

    Posted 19 Jan 2012 Link to this post

    Thanks.  I had visited several Telerik demo sites as well as searching the forums before I posted.  Nothing I found worked.

    I eventually got everything working by removing the AjaxManager.

    Thank you for your assistance.
Back to Top