单击按钮表单后不起作用。伙计们有什么想法吗?
剃刀视图
<div id="contactform">
<h3>
Contact Form</h3>
@using (Html.BeginForm("contacts", "Home"))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<fieldset>
<ol>
<li>
@Html.TextBoxFor(m => m.Name)
@Html.ValidationMessageFor(m => m.Name)
</li>
<li>
@Html.TextBoxFor(m => m.Email)
@Html.ValidationMessageFor(m => m.Email)
</li>
<li>
@Html.TextBoxFor(m => m.Phone)
@Html.ValidationMessageFor(m => m.Phone)
</li>
<li>
@Html.TextAreaFor(m => m.Message)
@Html.ValidationMessageFor(m => m.Message)
</li>
</ol>
<input type="button" value="contacts"/>
</fieldset>
}
</div>
模型
public class ContactModel
{
[Required]
[DataType(DataType.Text)]
[Display (Name="Name")]
public string Name { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[Display (Name="Email")]
public string Email { get; set; }
[Required]
[Display (Name="Phone")]
public string Phone { get; set; }
[Required]
[DataType(DataType.MultilineText)]
[Display(Name = "Message")]
public string Message { get; set; }
}
家庭控制器
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult contacts(ContactModel contact)
{
if (ModelState.IsValid)
{
}
return View();
}