【发布时间】:2019-08-26 16:16:01
【问题描述】:
如何在 C# MVC5 中提交带有参数值的表单?我已尝试使用以下示例,但它没有正确路由到控制器操作。
@Html.ActionLink("提交访问", "EditSubmit", "Home", new { warLineItemId = @ViewBag.WarLineItem.Id, customerNumber = @ViewBag.customerInfo.Number, warId = @ViewBag.WarId } , new { @class= "btn btn-primary btn-sm pull-right" })
【问题讨论】:
-
public ActionResult EditSubmit(int warId, int customerNumber, int warLineItemId) { NameValueCollection nameValueCollection = Request.Form; WarLineItemManager.Save(warLineItemId, warId, WarLineItemManager.GetMemberInformation().UserName, nameValueCollection); Session["Success"] = "WAR 提交成功!!!"; return Json("成功", JsonRequestBehavior.AllowGet); }
-
请阅读How to Ask,然后阅读edit您的问题并格式化您的代码(缩进4个空格,或使用
{}按钮)。不要添加 cmets 来澄清,edit 你的问题。照原样,你的问题是不可读的。还请包括您所说的“未提交”的含义。任何错误(在服务器日志中)? -
删除 AJAX 标签,因为它们没有使用 ajax,格式化代码和清理问题