I have JS code something like shown below:
function ValidateBid(source, args) {
var txtValue = $('#txtBid').val();
$.ajax({
type: "POST",
async: true,
url: "BidDetail.aspx/ValidateValue",
contentType: "application/json; charset=utf-8",
data: "{value:" + JSON.stringify(txtValue) + "}",
dataType: "json",
success: function (msg) {
var resultAsJson = msg.d // your return result is JS array
args.IsValid = msg.d;
// Now you can loop over the array to get each object
}
});
return args.IsValid;
}
Here what happens is, it returns args.IsValid first and then it goes into the method args.IsValid. I have used CustomValidator and i am calling this function on its ClientValidationFunction.
What i want is, i want to return true or false on the basis of what Json Function ValidateValue returns.
The request is async so it will return value before it is set. So I think if you change
async:falsewill work.