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

RadButton OnClientClicked Firing on Page_Load

1 Answer 492 Views
Button
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 25 Dec 2014, 03:00 PM
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!

BUTTON DEFINITIONS
<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" />


JAVASCRIPT FUNCTION

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";
 
    document.forms["form1"].submit();
 
}






1 Answer, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 26 Dec 2014, 11:18 AM
Hi Lynn,

I isolated the scenario to this configuration:
<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" OnClientClicked="makeNew" />
 
<telerik:RadButton ID="CloseMe" runat="server" Text="Close Window"
    CausesValidation="False" ToolTip="Closes this window."
    UseSubmitBehavior="false"/>
 
 
<script>
    function makeNew(sender, eventArgs) {
        alert("Button Clicked!");
        document.forms["form1"].submit();
    }
</script>

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.

Regards,
Ianko
Telerik
 

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.

 
Tags
Button
Asked by
Lynn
Top achievements
Rank 2
Answers by
Ianko
Telerik team
Share this question
or