I have posted a similar question to this problem and could answer it myself, but the solution does not fully satisfy me.
Using Asp.Net/C#, I have a button which will perform some server-side code if it passes a client-side validation. I want to do it this way because for my application, I think it suits best.
<asp:Button runat="server" ID="addBtn" Text="Add" OnClientClick="if(validateEntry()== false){return false;}" OnClick="addBtn_Click"/>
I call a jQuery function named validateEntry() which uses PageMethods to get some data from the server. The data are necessary for the validation process.
function validateEntry() {
PageMethods.CheckEntry(params, function(result){//Evaluate result of PageMethods}
}
My problem is I do not know how to handle the data received from PageMethods properly. I am only able to hand them over to a sub-function which can use them. But I need the data in sort of variable to perform a return false.