tags:

views:

61

answers:

3

I am returning partial view

public virtual PartialViewResult Create()
{
    return PartialView("Create");
}

and loading the view in my page when clicking create button with jquery

function createVendor() {
    jQuery.ajax({
        type: 'GET',
        url: 'Vendor/create',
        success: function (result) {
            $("#popup").html(result).fadeOut('slow').fadeIn('slow');
        }
    });
}

in my class I am using DataAnnotations for validation, making reference for js files and add adding

<% Html.EnableClientValidation(); %>

before begin form.

the problem is that when I click save the first time with wrong data the validation not working but it is working the second time I click save.

A: 

My understanding of the EnableClientValidation() is that it examines the model and injects html wherever it needs to go. So you may need to call EnableClientValidation() again in your partial view you return.

TJB
I already added it to my partial view and to my page that I am loading the partial view in and the validation still working the second time only.
Mazen
A: 

Is this a bug in Mvc or what?!!!

no one answer my question.

Mazen
A: 

Dear all I found the answer here thanks for you :

http://weblogs.asp.net/imranbaloch/archive/2010/07/11/asp-net-mvc-client-side-validation-with-dynamic-contents.aspx

Mazen