提交按钮在Razor中不起作用asp.net mvc

时间:2019-05-07 19:24:20

标签: c# asp.net-mvc razor

我有一个如下所示的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,已经做到了,但是没用,有什么主意吗?谢谢。

1 个答案:

答案 0 :(得分:2)

您未指定在何处张贴该表格... $('#Last 30 days').trigger('click'); $('#Last 30 days').click(); 可以使用several parameters。您应该指定Html.BeginFormActionName

ControllerName

注意:“控制器”将是您的控制器的名称。