我有强类型视图,我想在控制器中获取数据。这就是我所拥有的:
@model WordAutomation.Models.Document
@{
ViewBag.Title = "Document";
}
<h2>Document</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Document</legend>
<div class="editor-label">
@Html.LabelFor(model => model.CaseNumber)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CaseNumber)
@Html.ValidationMessageFor(model => model.CaseNumber)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
然后,在控制器中我有这个:
[HttpPost]
public ActionResult Document(FormCollection formValue)
{
string test = formValue[0].ToString();
return View();
}
但是没有数据出现。知道我在做什么错吗?谢谢