RadButton and OnClientClick

3 posts, 0 answers
  1. Chris
    Chris avatar
    28 posts
    Member since:
    Jun 2012

    Posted 01 Dec 2011 Link to this post

    Hi All,

    New to these controls so please forgive my igmnorance - I have come from an Infragistics background.  I wanted to create a simple page with 3 large buttons which when clicked would take you to the appropriate web page.  Easy I thought!
    I declare my button as :-

    <telerik:RadButton ID="btnTeamData" runat="server" Text="Team Data" Height="70px" Width="250px" Font-Size="18px" Icon-PrimaryIconUrl="~/Images/indycar_48.png"
    Icon-PrimaryIconWidth="48" Icon-PrimaryIconHeight="48" AutoPostBack="False" Icon-PrimaryIconTop="10"
    ToolTip="combined data recovered from the Teams">

    ...and I have a javascript function at the top of the page
    <script type="text/javascript" language="javascript"> 

    function btnTeamView_OnClientClicked()
    alert('Team View');
    document.location.href = './teamview.aspx';


    ...what's odd is that as soon as the page loads I get the alert and the page tries to jump off to the specified new page.  I haven't clicked the button so why is it calling the OnClientClicked event?  How do I get this to work as I would expect?


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2011 Link to this post


     I have tried to reproduce the issue but no avail. Here is the sample code.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadButton.aspx.cs" Inherits="RadButton" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <form id="form1" runat="server">
            <asp:ScriptManager ID="scriptmngr" runat="server">
            <telerik:RadButton ID="RadButton1" runat="server" Text="Click " Height="70px" Width="250px"
                Font-Size="18px" Icon-PrimaryIconWidth="48" Icon-PrimaryIconHeight="48" OnClientClicked="OnClientClicked"
                ToolTip="combined data recovered from the Teams" AutoPostBack="false">
    <script type="text/javascript">
     function OnClientClicked()
         window.location.href = './Home1.aspx';

    Also take a look into the following documentation

  3. Slav
    Slav avatar
    1359 posts

    Posted 06 Dec 2011 Link to this post

    Hello Chris,

    The original code sample seems valid, so I would suggest checking if any of the other RadControls on your page (if there are such), is throwing a JavaScript error and if their setup is correct. Note that the handlers of all RadControls' client events should be specified only by the name of the handler function or by a function object, otherwise their client objects won't be created properly, which will result in an unexpected behavior as the one you have experienced.

    If the information presented above does not help you resolve your difficulties please open a regular support ticket and send us a simple, runnable project that isolates your case so that we can inspect it locally and pinpoint the cause.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top