
278Microsoft Visual Studio 2010: A Beginner’s Guide
<div
<%= Html.TextBoxFor(model => model.Age) %> <%= Html.ValidationMessageFor(
model => model.Age) %>
</div>
<div
<%= Html.LabelFor(model => model.Birthday) %> </div>
<div
<%= Html.TextBoxFor(model => model.Birthday) %> <%= Html.ValidationMessageFor(
model => model.Birthday) %>
</div>
<div
<%= Html.LabelFor(model => model.Income) %> </div>
<div
<%= Html.TextBoxFor(model => model.Income) %> <%= Html.ValidationMessageFor(
model => model.Income) %>
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
<% } %>
<div>
<%=Html.ActionLink("Back to List", "Index") %> </div>
</asp:Content>
The ValidationMessageFor Html helper displays any errors that occur on this page. The error messages are displayed whenever the Controller action method adds the error to the ModelState. When the user clicks the Submit button, this page will post back to the Create method with the AcceptVerbs attribute for post. Figure
In addition to creating a new Customer, you can edit existing Customers, as is discussed next.