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

Disable OnClick event calling in OnClientClicked

1 Answer 457 Views
Button
This is a migrated thread and some comments may be shown as answers.
Gustavo
Top achievements
Rank 1
Gustavo asked on 02 Dec 2014, 06:54 PM
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?

Exemple:
<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();
    batchManager.addNewRecord(grid.get_masterTableView());
  }
}

Thanks

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 03 Dec 2014, 02:36 PM
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.

Regards,
Danail Vasilev
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
Gustavo
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or