下面是我的.cshtml中的代碼,並有兩個按鈕,但我無法通過單擊任何按鈕來調用我的操作方法。HttpPost沒有在MVC中點擊保存按鈕後被調用
@model IList<ClaimBuildMVC.ClaimBuildBE.ManageUsersBE>
@{
ViewBag.Title = "GetEditRecord";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="Content-inner-pages">
<div class="Accountsettings">
<h2><span>Edit User Details</span></h2>
<div class="box">
<div class="box-content">
<div class="form-horizontal form-details">
<div class="form-group">
<label class="col-xs-4 col-sm-4 col-md-2 control-label">First Name</label>
<div class="col-xs-8 col-sm-8 col-md-4">
@Html.TextBox("FirstName", (string)ViewBag.FirstName, new { @class = "form-control", @id = "FirstName" })
</div>
</div>
<div class="form-group">
<label class="col-xs-4 col-sm-4 col-md-2 control-label">Last Name</label>
<div class="col-xs-8 col-sm-8 col-md-4">
@Html.TextBox("LastName",(string)ViewBag.LastName, new { @class = "form-control", @id = "LastName" })
</div>
</div>
<div class="form-group">
<label class="col-xs-4 col-sm-4 col-md-2 control-label">Role</label>
<div class="col-xs-8 col-sm-8 col-md-4">
@Html.TextBox("RoleName",(string)ViewBag.FkRoleId,
new { @class = "form-control", @id = "RoleName" })
</div>
</div>
<div class="form-group">
<label class="col-xs-4 col-sm-4 col-md-2 control-label">Status</label>
<div class="col-xs-8 col-sm-8 col-md-4">
@Html.DropDownList("Status", new List<SelectListItem> { new SelectListItem{ Text="Active", Value = "0" }, new SelectListItem{ Text="InActive", Value = "1" }
}, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
<div class="col-xs-8 col-sm-8 col-md-4 col-md-offset-2 col-sm-offset-4 col-xs-offset-4">
<input type="submit" value="Save" name="actiontype" class="btn-class btn-success">
<input type="reset" value="Cancel" name="actiontype" class="btn-class btn-danger">
</div>
</div>
</div>
</div>
</div>
</div>
,在我的控制器
[HttpPost]
public ActionResult GetEditRecord(ManageUsersBE MU,string actiontype)
{
if (actiontype == "Save")
{
my logic
}
return View("ManageUsersBE");
}
所以當我把連我的調試器上後,點擊保存按鈕,它不調用到controller.Am我misiing something.Please幫助
包裹內的形式,利用你的HTML無論是普通的HTM l或Html.Begin形式從剃刀 –
@Reddy你可以給我example.i我非常新MVC – Steve
是的,有一個支票 –