Edit this page

Client-side Click Event Handler Is Not Executed

The RadButton, just like the rest of the Telerik controls, only needs the name of the JavaScript function that will be a handler for its client-side events.

Its client-side click events are OnClientClicking and OnClientClicked to be uniform with the rest of the controls.

The AutoPostBack property, when set to false, has the same effect as adding the return false; statement to the OnClientClick handler for the regular ASP button. Alternatively, you can cancel the OnClientClicking event to avoid the postback.

Below is shown a comparison between ASP button and RadButton client-side event handling (Example 1 and Example 2).

Example 1: Handling client-side click event of ASP Button without performing a postback.

<script type="text/javascript">
    function ButtonClick(button) {
        alert("The Button with ID " + button.id + " was clicked.");
    }
</script>

<asp:Button ID="Button1" Text="Regular Button" OnClientClick="ButtonClick(this); return false;"
    runat="server" />

Example 2: Handling client-side click event of RaButton without performing a postback.

<script type="text/javascript">
    function ButtonClick(sender, args) {
        alert("The Button with ID " + sender.get_uniqueID() + " was clicked.");
    }
</script>

<telerik:RadButton RenderMode="Lightweight" runat="server" ID="RadButton1" Text="RadButton" OnClientClicked="ButtonClick"
    AutoPostBack="false">
</telerik:RadButton>

More information is available in the Migrating OnClientClick handlers from ASP button to Telerik’s ASP.NET AJAX Button blog post.

See Also