ボタンフォームポストをクリックすると、機能しません。みんな考えた?
Razor VIew
<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();
}