I have View with Model1 where I put Ajax.BeginForm()
and in this View i have PartialView with Model2 where i put Ajax.BeginForm()
. So only in first form working unobtrusive validation
. Why only in first form working validation?
first View
@model Model1
@using (Ajax.BeginForm("Action1","Controller",null,new AjaxOption(){ onSuccess = "alert('=)')"},null)
{
<intput type="submit" value="Save" />
}
Model2 model2 = new Model2();
@Html.EditorFor(m=>model2)
**In Model2 view i have. **
@model Model2
@using (Ajax.BeginForm("AddStreet","Controller",new AjaxOption(){onSuccess = "alert('=)'")},option,null)
{
@Html.LabelFor(m => Model.Name):
@Html.TextBoxFor(m => Model.Name)
@Html.ValidationMessageFor(m => Model.Name)
<intput type="submit" value="Save" />
}
Thanks @Darin Dimitrov for answer.
See Question&Answers more detail:os