In this case you need to use this approach:
C#:
public bool validate( string OrderID, string ShipName, string ShipCity, string ShipCountry){
if ( OrderID == String.Empty || ShipName == String.Empty
|| ShipCity == String.Empty || ShipCountry == String.Empty )
{
return false;
}
return true;
}
JavaScript:
var flagUpdated = false;
function OnBeforeUpdate(record)
{
if ( flagUpdated )
{
flagUpdated = false;
return true;
}else{
// send ajax request to test the values server-side
ob_post.AddParam("OrderID", record.OrderID);
ob_post.AddParam("ShipName", record.ShipName);
ob_post.AddParam("ShipCity", record.OrderID);
ob_post.AddParam("ShipCountry", record.ShipCountry);
ob_post.post(null, "serverSideValidateMethod", processAjaxResult );
}
return false;
}
function processAjaxResult( result ) {
if (result == true)
{
onServerSuccess();
}else{
onServerUnsuccess();
}
}
And the client-side callback functions will look like this:
function getRecordInEditMode(){
return grid1.RecordInEditMode;
}
function onServerSuccess(result, eventArgs)
{
var oRecord = getRecordInEditMode();
flagUpdated = true;
grid1.update_record(oRecord);
}
function onServerUnsuccess(result, eventArgs)
{
var oRecord = getRecordInEditMode();
grid1.cancel_edit(oRecord);
}