MVC3 ajax validation doesn't work on a jquery served form
Tech-Today

MVC3 ajax validation doesn't work on a jquery served form


To make automatic validation using data annotation on a model on mvc3 c# we need:
1.) A model with data annotation (ex. required attribute).
2.) Form with jquery declaration (jquery1.7, validate, validate unobtrusive, and unobtrusive-ajax. All are available under Scripts directory on an MVC template project. Note that you can update your jquery library using NuGet.
3.) App.config with <add key="ClientValidationEnabled" value="true"/> defined.

Normally, with this requirement validation should work fine. But if the form is served via ajax call, you need to rebind the form to the validator elements  using the ff code:

//your_div is the id of your element which contains the form
$.validator.unobtrusive.parse($('#your_div'));




- How To Upload A File In An Mvc3 C# Ajax Form
It's easy to upload file in a synchronous form, where you just post the file and read a HttpPostedFile variable in the server side: In plain html form, take note of the form enctype property: //the view (index.cshtml) @using (Html.BeginForm("Upload",...

- Add A Jquery Datepicker On Jquery Dialog Box Via Load Method
Recently I've worked on a form that requires a jquery datepicker to be rendered inside jquery's dialog element. Where I encountered several problems like: 1.) datepicker() should be invoke inside dialog 2.) the dialog created (div) should be remove...

- Adding Loading Screen To C# Mvc Ajax Dialog Form Using Jquery
With my experience from telerik, I want my entity's add and edit form to be a popup so I don't have to change screen. I'm using C# MVC3, so I tried to look for jquery add on that would do the job. Fortunately I've come up with this article:...

- Validation-summary-errors Div Showing Even If There Is No Error Binded To A Property
I'm working on a change password form when I encountered this strange behavior from mvc3. I created a simple form and change password model with 3 fields (old, new, confirm password). Then I extended ValidationAttribute to validate the password's...

- Jquery Copy Form Values Into Another Form
Recently I have a requirement to have two form on a single page. Why? It's because I have a search form that query records from the database with the aid of ajax. Then another form to generate a report based from the filters specified in the first...



Tech-Today








.