【发布时间】:2015-09-15 15:29:21
【问题描述】:
我创建了一个视图来输入结果并反馈给控制器,在那里我可以将它们保存到数据库中,但是当我单击提交时,我将返回到 GET actionresult,我尝试将 BeginForm 放入其中确实有效,但是它通过将所有输入文本框塞在一起完全改变了我视图中的显示。如何保留现有布局并提交到 POST actionresult?`
@{
ViewBag.Title = "CreateLecturer";
}
<br /><br /><br /><br />
<form class="form-horizontal">
@using (Html.BeginForm("CreateLecturer", "Admin", new { }, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<fieldset>
<legend>Add Lecturer</legend>
<div class="form-group">
<label for="addLect" class="col-lg-2 control-label">Lecturer Number</label>
<div class="col-lg-4">
<input type="text" class="form-control" id="addLect" name="addLect" placeholder="Lecturer Number">
</div>
</div>
<div class="form-group">
<label for="addLectFname" class="col-lg-2 control-label">Firstname</label>
<div class="col-lg-4">
<input type="text" class="form-control" id="addLectFname" name="addLectFname" placeholder="Firstname">
</div>
</div>
<div class="form-group">
<label for="addLectSname" class="col-lg-2 control-label">Surname</label>
<div class="col-lg-4">
<input type="text" class="form-control" id="addLectSname" name="addLectSname" placeholder="Surname">
</div>
</div>
<div class="form-group">
<label for="addLectPword" class="col-lg-2 control-label">Password</label>
<div class="col-lg-4">
<input type="password" class="form-control" id="addLectPword" name="addLectPword" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
@Html.ActionLink("Cancel", "ViewLecturer", "Admin", null, new { @class = "btn btn-warning" })
<button type="reset" class="btn btn-default">Clear</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
}
</form>
`
【问题讨论】:
标签: html asp.net-mvc asp.net-mvc-4 razor