[英]Submit Button is not working In Razor asp.net mvc
我有一个ViewModel,Controller和View,如下所示
public class H2HViewModel
{
public DateTime EffectiveDate { get; set; }
public byte TransferMethod { get; set; }
public string ListOfSelectedBatchID { get; set; }
}
控制者
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(H2HViewModel model)
{
var detailPayments = db.Payments.Where(x => x.Status == 2).ToList();
foreach (Payment detail in detailPayments)
{
detail.PaymentStatus = 4;
detail.EffectiveDate = model.EffectiveDate;
detail.TransferMethod = model.TransferMethod.ToString();
}
db.SaveChanges();
return RedirectToAction("Dashboard", "User");
}
视图
@model EPayment.Data.ViewModels.H2HViewModel
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.EditorFor(model => model.EffectiveDate, new { @class = "form-control dtpicker" })
<div class="col-md-10">
@Html.RadioButtonFor(model => model.TransferMethod, "AB", new { htmlAttributes = new { @class = "form -control" } }) AB
@Html.RadioButtonFor(model => model.TransferMethod, "BC", new { htmlAttributes = new { @class = "form -control" } }) BC
</div>
<input type="submit" value="Submit" class="btn btn-default"/>
}
当我单击提交按钮时,什么都没有发生,我在ActionResult Create上创建了一个断点来对其进行调试,但是也没有任何反应。 我指的是这个stackoverflow.com/questions/16443927 ,并且已经做到了,但是没有用,是什么主意? 谢谢。
您没有指定要在何处张贴该表格... Html.BeginForm
可以采用多个参数 。 您应该指定ActionName
和ControllerName
@using (Html.BeginForm("Create", "Controller", FormMethod.Post))
注意:“控制器”将是您的控制器的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.