I have a textbox and I 开发者_JAVA百科do CustomValidation which does client side and server side validations, how do I fire both client side and server side validations at once? now server side validation fires only after client side validation.
is it possible?
Basically : No, you can rise one after the other if you need but client side validation is there to avoid having to call the server in order to validate. If you need to call the server anyway, why do you bother writing client validation script ?
edit :
If you want the server validation to take place before the form is posted, I suggest you use Ajax to call the server validation routine within you client side validation script. It requires a little trick because Ajax is asynchronous by definition while the client side validation is not. Start here : http://www.codeproject.com/KB/ajax/AjaxValidation.aspx
Client and server side validations can have different purposes and one cant always assume to stay safe with client side validations.
By default, once the client events are over, the request is sent out to the server and that's how the page cycle takes place. But if you need to send a server request directly, you would need to make use of AJAX and send an async request.
But logically, It would be advisable to handle the two validations separately, for a cleaner and better approach.
I'm guessing you have some CustomValidator that only has a server-side implementation, and it runs after your regular validators have already run. That way the user would first be presented with validation errors from the regular validators, and after fixing those, has to go through the custom validator, which is confusing. I suggest turning off all client validation (set EnableClientValidation to false), and running the whole thing server-side only. That way all validators run at the same time.
Menno
精彩评论