I have enabled unobtrusive client side validation in my app, and I have (something similar) to this model:
public class MyModel
{
[Required]
public strin
Ahh... simple :)
The @Html.BeginForm()
must be in the same partial (which I guess is fair enough, since we are validating on a form), so:
/Home/Index view becomes:
@model MyModel
@Html.Partial("Model")
With the partial "Model":
@model MyModel
@using (Html.BeginForm("Test", "Home"))
{
@Html.LabelFor(x => x.Name)
@Html.TextBoxFor(x => x.Name)
@Html.ValidationMessageFor(x => x.Name)
@Html.LabelFor(x => x.Age)
@Html.TextBoxFor(x => x.Age)
@Html.ValidationMessageFor(x => x.Age)
}