有一个与你的价值观接触的模型,如:
ContactModel
string title { get; set; }
string firstName { get; set; }
string lastName { get; set; }
string email { get; set; }
string phone { get; set; }
string mobile { get; set; }
string message { get; set; }
Run Code Online (Sandbox Code Playgroud)
在您的控制器中,您可以创建一个方法(与您的视图相同的名称)
的ContactController
public ActionResult Contact(ContactModel newModel)
{
//Do what you need to do
return View();
}
Run Code Online (Sandbox Code Playgroud)
在你看来,这样做:
联系
@model YourProjectName.Models.ContactModel
@using (Html.BeginForm("Contact", "Contact")) //send data to controller (Method name, Controller name)
{
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.title)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.title)
</div>
// Do the same to all other values
<input type="submit" value="Send" />
</fieldset>
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5785 次 |
| 最近记录: |