问题
I'm trying to do some validation checks on the client side but my ASP.NET MVC application fails even before opening the index page. I get the error Microsoft Jscript runtime error: unable to get value of the property 'call':object is null or undefined.
Below is my script. I'm using partial views to show a UI dialog to edit the employees. I've made sure that the jqueryval bundle is added to the _Layout.cshtml and clientsidevalidation is set true. any help would be greatly appreciated - thanks
var $form = $("#updateEmployeeForm");
$form.unbind();
$form.data("validator", null);
// Check document for changes
$.validator.unobtrusive.parse(document);
// Re add validation with changes
$form.validate($form.data("unobtrusiveValidation").options);
dialogDiv.dialog('open');
partial view
@using (Ajax.BeginForm("EditEmployee", "Employee", new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "updateSuccess"
}, new { @id = "updateEmployeeForm" }))
{
@Html.ValidationSummary(true) .....}
My viewModel
[Required]
public string FirstName { get; set; }
public string MiddleName { get; set;}
[Required]
回答1:
Thanks to Slicksim
"I believe i have seen this when using jquery > 1.9 with asp.net mvc. try installing jquery 1.8.2 and see if that solves it. i think there is an issue with the unobtrusive ajax or validator with the new version of jquery – Slicksim Apr 2 at 10:30"
That is the solution. Go to a previous Jquery.
来源:https://stackoverflow.com/questions/15749471/jquery-validation-error-in-asp-net-mvc-unable-to-get-value-of-property-call