at razor , if we have 3 partial views each contains a validation summary control
when the validation works, and the validation summary supposed to give the usual red text , all the validations summary controls will view the error , even if the element that have the problem is not it its own view
example
The solution:
the solution is to draw the validation summary only when you validate your form for example
- at the controller of "RegisterForm" , set the Session["ValidationSummary"] = "RegisterForm"
- at the controller of "LoginForm" , set the Session["ValidationSummary"] = "LoginForm"
- at the RegisterForm view
if ( Session["ValidationSummary"] == "RegisterForm")
{@Html.ValidationSummary();
}
4. at the
LoginForm view
if ( Session["ValidationSummary"] == "
LoginForm ")
{
@Html.ValidationSummary();
}
you can find nother solution here NamedValidationSummary
No comments:
Post a Comment