我在移动网站上工作,我使用剃须刀引擎创建了我的代码来从 ID 的数据库中检索字段。我为 ID 添加了默认值,但我想要来自隐藏控件的 ID。
看法:
<fieldset>
<legend></legend>
@Html.HiddenFor(model=>model.ID)
<div class="editor-label ">
@Html.LabelFor(model => model.User)
</div>
<div class="editor-field create-Bt3">
@Html.EditorFor(model => model.User)
@Html.ValidationMessageFor(model => model.User)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field create-Bt3">
@Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<div>
<p class="create-Bt ">
<input type="submit" value="Insert" />
</p>
</div>
</fieldset>
控制器:
[HttpPost]
public ActionResult LoginIndex(string Role)
{
var data = db.Login.ToList();
if (Role == "DataEntry")
{
Response.Redirect("../Category/Index");
}
else
{
Response.Redirect("../Login/Index");
}
return View();
}