e.g. 3.15 Using the Html.ValidationSummary Help Method

This commit is contained in:
Jason Zhu 2021-07-14 21:38:20 +10:00
parent 044c51ef8b
commit ebfdf467e0
2 changed files with 2 additions and 1 deletions

View File

@ -12,7 +12,7 @@ namespace PartyInvites.Models
ErrorMessage = "Please enter a valid email address")]
public string Email { get; set; }
[Required(ErrorMessage = "Please enter your name")]
[Required(ErrorMessage = "Please enter your phone number")]
public string Phone { get; set; }
[Required(ErrorMessage = "Please specify whether you'll attend")]

View File

@ -13,6 +13,7 @@
<body>
@using (Html.BeginForm())
{
@Html.ValidationSummary()
<p>Your name: @Html.TextBoxFor(x => x.Name)</p>
<p>Your email: @Html.TextBoxFor(x => x.Email)</p>
<p>Your phone: @Html.TextBoxFor(x => x.Phone)</p>