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

RadButton in RadGrid not firing

3 Answers 118 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 16 Jan 2012, 06:04 PM
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

3 Answers, 1 is accepted

Sort by
0
Rick
Top achievements
Rank 1
answered on 17 Jan 2012, 02:57 PM
PS - If there is any additional information you need in order to reply and help, please let me know.
0
Richard
Top achievements
Rank 1
answered on 17 Jan 2012, 09:19 PM
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!
0
Rick
Top achievements
Rank 1
answered on 19 Jan 2012, 03:52 PM
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.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Rick
Top achievements
Rank 1
Answers by
Rick
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or