ServerSide Validation through validation object
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@if (Model.Customer.Id==null|| Model.Customer.Id == 0)
|
||||
@if (Model.Customer.Id == null || Model.Customer.Id == 0)
|
||||
{
|
||||
<h2>New Customer</h2>
|
||||
}
|
||||
@ -17,17 +17,21 @@ else
|
||||
|
||||
@using (@Html.BeginForm("Save", "Customers"))
|
||||
{
|
||||
@Html.ValidationSummary(true, "Please fix the following errors.")
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Customer.Name)
|
||||
@Html.TextBoxFor(m => m.Customer.Name, new { @class = "form-control" })
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Customer.BirthDate)
|
||||
@Html.TextBoxFor(m => m.Customer.BirthDate, "{0:d MMM yyyy}", new { @class = "form-control" })
|
||||
@Html.ValidationMessageFor(m => m.Customer.Name)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Customer.MembershipTypeId)
|
||||
@Html.DropDownListFor(m => m.Customer.MembershipTypeId, new SelectList(Model.MembershipTypes, "Id", "Name"), "Select membership Type", new { @class = "form-control" })
|
||||
@Html.ValidationMessageFor(m => m.Customer.MembershipTypeId)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(m => m.Customer.BirthDate)
|
||||
@Html.TextBoxFor(m => m.Customer.BirthDate, "{0:d MMM yyyy}", new { @class = "form-control" })
|
||||
@Html.ValidationMessageFor(m => m.Customer.BirthDate)
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
|
||||
Reference in New Issue
Block a user