[英]Submit Button is not working In Razor asp.net mvc
I have a ViewModel, Controller and View like below 我有一个ViewModel,Controller和View,如下所示
public class H2HViewModel
{
public DateTime EffectiveDate { get; set; }
public byte TransferMethod { get; set; }
public string ListOfSelectedBatchID { get; set; }
}
Controller 控制者
[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");
}
View 视图
@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"/>
}
when I click the submit button nothing happens, I made a breakpoints on ActionResult Create to debug it, but nothing happened too. 当我单击提交按钮时,什么都没有发生,我在ActionResult Create上创建了一个断点来对其进行调试,但是也没有任何反应。 I refer to this stackoverflow.com/questions/16443927 , and have done it but it didn't work, any idea?
我指的是这个stackoverflow.com/questions/16443927 ,并且已经做到了,但是没有用,是什么主意? thanks.
谢谢。
You're not specifying where to post that form... Html.BeginForm
can take several parameters . 您没有指定要在何处张贴该表格...
Html.BeginForm
可以采用多个参数 。 You should be specifying the ActionName
and ControllerName
您应该指定
ActionName
和ControllerName
@using (Html.BeginForm("Create", "Controller", FormMethod.Post))
Note: "Controller" will be the name of your controller. 注意:“控制器”将是您的控制器的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.