RadButton OnClientClicked Firing on Page_Load

2 posts, 1 answers
  1. Lynn
    Lynn avatar
    186 posts
    Member since:
    Sep 2006

    Posted 25 Dec 2014 Link to this post

    I am having a problem where the first RadButton on a webform fires on Page_Load (without being clicked at all).

    I have read other similar threads, but they all say to delete the () after the function name in the OnClientClicked property...I have done this and it makes no difference what so ever.  The button OnClientClicked event always fires --- except after the page is loaded, then the OnClientClicked event NEVER fires).

    I have keyed and rekeyed the property numerous times and it always screws up.  What should I do?

    The buttons definitions and the javascript are provided below.  Thanks in advance for any help!

    <telerik:RadButton ID="CreateNew" runat="server" Text="Create New" CausesValidation="False" ToolTip="Displays a form for adding a new Master Agent Billing set to the database." UseSubmitBehavior="false" OnClick="CreateNew_Click" OnClientClicked="makeNew" />
    <telerik:RadButton ID="CloseMe" runat="server" Text="Close Window" CausesValidation="False" ToolTip= "Closes this window." UseSubmitBehavior="false" OnClientClicked="closemenow" />


    function makeNew(sender, eventArgs) {
        document.getElementById('<%= HiddenField1.ClientID%>').value = "myTarget;
        document.getElementById('<%= K.ClientID%>').value = "0";
        document.getElementById('<%= KI.ClientID%>').value = "0";
        document.getElementById('<%= KII.ClientID%>').value = "0";
        document.getElementById('<%= M.ClientID%>').value = "N";
        document.getElementById('<%= MI.ClientID%>').value = "N";
        document.getElementById('<%= MII.ClientID%>').value = "N";

  2. Answer
    Ianko avatar
    1738 posts

    Posted 26 Dec 2014 Link to this post

    Hi Lynn,

    I isolated the scenario to this configuration:
    <telerik:RadButton ID="CreateNew" runat="server" Text="Create New"
        ToolTip="Displays a form for adding a new Master Agent Billing set to the database."
        UseSubmitBehavior="false" OnClientClicked="makeNew" />
    <telerik:RadButton ID="CloseMe" runat="server" Text="Close Window"
        CausesValidation="False" ToolTip="Closes this window."
        function makeNew(sender, eventArgs) {
            alert("Button Clicked!");

    Running it on a page, shows the alert only when the first button is clicked. The OnClientClicked event is raised only after clicking, and I am unable to reproduce the described behavior.

    Also, when setting a handler property to a client-side function, you should make sure that this functionality exists in the global scope. If it does not exist a JS error is thrown and the button fails to act as expected.

    You can also examine the RadButton's event sequence with the Client-side Events demo, where you can see that the clientClicked event is fired only after click.

    If you are still able to reproduce the issue, please provide more details about the exact situation. Also, you can provide a simple project that would allow me to locally reproduce the situation and examine it properly.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top