I have an ASP button that executes some JavaScript "Generate()" and then the code behind "Button2_Click".
<asp:Button OnClientClick="Generate();" OnClick="Button2_Click" Text="New Baseline >>>" class="btn btn-primary" runat="server" Style="float: right;"/>
If "count" is greater than 0, I want to prevent the code behind from executing
function Generate() {
var count = 0
var ids = jQuery("#<%= JQGrid1.ClientID %>").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var rowId = ids[i];
var rowData = jQuery("#<%= JQGrid1.ClientID %>").jqGrid('getRowData', rowId);
//alert(rowData.Action);
if (rowData.Action == null || rowData.Action == "") {
count += 1
}
}
if (count > 0) {
alert('You must complete all of the Actions fields first!');
return false;
} else {
//All Action fields complete, continue to code behind...
}
};
I have tried return false, but that does not stop the code behind.