Last post Aug 11, 2014 05:10 AM by willyx2001
Aug 10, 2014 06:56 AM|willyx2001|LINK
Hi, How do i do server side validation for an ajax form post?
This article by mike shows how to use validation when posting to same page
His Ajax article shows the ajax but no validation
So how do i validate server side when using ajax?? can anyone give me an example.
Also I don't seem to be able to use any response.redirect requests in the code my ajax sends the form data to?
I cant understand why as this this is server side and the ajax is client
thanks for any help
Aug 10, 2014 03:32 PM|Mikesdotnetting|LINK
You can use the validators with an AJAX form submit, but only the client-side validation will work - unless you are submitting to the same page. If you are submitting to a different page, you need to write your own server-side validation in that page. That's
just a question of writing code to ensure hat the user input meets your business rules. You might want to send back an object (JSON) to indicate validation success or failure.
If you call Response.Redirect in the page that processes your AJAX forum submission, a request will be made to the target page, but as part of the AJAX call. The page that the AJAX call was made from will not be affected. The only way to move the user from
the initial page is to do that on the client which you can do using location.href.
Aug 11, 2014 05:10 AM|willyx2001|LINK
That clears up a lot of confusion for me...many thanks for your help Mike