Disable OnClick event calling in OnClientClicked

2 posts, 0 answers
  1. Gustavo
    Gustavo avatar
    23 posts
    Member since:
    Apr 2012

    Posted 02 Dec 2014 Link to this post

    Is it possible to use the OnClientClicked property of a RadButton to do a clientside check and if the check returns true, then fire the onclick event. If the clientside check returns false, don't fire the onclick event.

    Is that possible?

    <asp:CheckBox ID="ckBoxAutoFill" runat="server" Text="Auto Fill" />
    <telerik:RadButton ID="btnAddNew" runat="server" OnClientClicked="addNewRecord" OnClick="btnAddNew_Click" Text="Add">
    function addNewRecord(sender, args) {
      var ckBox = document.getElementById("<%=ckBoxAutoFill.ClientID%>");
      if (ckBox.checked) {
        //execute onclick event btnAddNew_Click
      else {
        //don't execute onclick event and execute the code below
        var grid = $find("<%=radGrid1.ClientID%>");
        var batchManager = grid.get_batchEditingManager();

  2. Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 03 Dec 2014 Link to this post

    Hi Gustavo,

    If you want to cancel the postback you must use the OnClientClicking event because it is cancelable and especially the set_cancel(true) method exposed by the arguments.

    Danail Vasilev

    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