1) Server
@{
ViewBag.Title = "ContactForm";
}
<h2>Contact Info</h2>
@using (Html.BeginForm())
{
@Html.Label("Name")
@Html.TextBox("Name")
@Html.ValidationMessage("Name")
<br />
@Html.Label("Email")
@Html.TextBox("Email")
@Html.ValidationMessage("Email")
<br />
@Html.Label("Comments")
@Html.TextBox("Comments")
@Html.ValidationMessage("Comments")
<br />
<button type="submit">Submit</button>
}
2) Client
@model test2.Models.ContactModel
@{
ViewBag.Title = "ContactForm";
}
<h2>@ViewBag.Message</h2>
@using (Html.BeginForm())
{
@Html.LabelFor(model=> model.Name)
@Html.TextBoxFor(model=> model.Name)
@Html.ValidationMessageFor(model=> model.Name)
<br />
@Html.LabelFor(model=> model.Email)
@Html.TextBoxFor(model=> model.Email)
@Html.ValidationMessageFor(model=> model.Email)
<br />
@Html.LabelFor(model=> model.Email)
@Html.TextBoxFor(model=> model.Email)
@Html.ValidationMessageFor(model=> model.Email)
<br />
<button type="submit">Submit</button>
}