當登錄按鈕表單發佈不起作用。夥計們有什麼想法?MVC 3剃刀視圖BeginForm表單發佈不起作用
Razor視圖
<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();
}
請定義「帖子不工作」:您的操作未被擊中?你會得到什麼響應代碼?你在瀏覽器的開發工具/ firebug/fiddler中看到了這個請求嗎? – nemesv