I am new to mvc I am trying simple validation summary but the validation summary is not showing in UI.IS there any syntax wrong.
@{Html.ValidationSummary();}
@{Html.BeginForm();}
<p>
Name:-@Html.TextBox("Name")
</p>
<p>
Age:-@Html.TextBox("Age")
</p>
<input type="submit" value="Sign In" />
<h6>SignIn</h6>
@{Html.EndForm();}
This should work:
...Assuming that you have validation attributes (e.g.
[Required]
) on the properties on the model.Notice that the validation summary is inside the
Html.BeginForm()
block.Also notice the
TextboxFor
syntax (rather thanTextbox
) which makes sure that your properties are strongly typed.Also, make sure you have these settings in the appsettings section of your web.config file: