简体   繁体   English

jQuery传递给MVC asp.net C#控制器

[英]jQuery to pass to MVC asp.net c# controller

I changed some things around for an item that was requested. 我为请求的商品更改了一些内容。 This required me to add a parameter to one of the controller ActionResults. 这需要我向控制器之一的ActionResults中添加一个参数。

public ActionResult RejectDocument(int id = 0, string rejectReason)
        {
            IPACS_Version ipacs_version = db.IPACS_Version.Find(id);

            ipacs_version.dateDeleted = System.DateTime.Now;
            ipacs_version.deletedBy = User.Identity.Name.Split("\\".ToCharArray())[1];

            db.SaveChanges();

            return RedirectToAction("Approve");
        }

Also this link needs to be activated from jQuery after some jQuery items finish. 同样,在某些jQuery项目完成后,还需要从jQuery激活此链接。 How do I pass this link off now? 现在如何关闭此链接?

should it be href= Document/RejectDocument?id=222&rejectReason=this is my reject reason 应该是href= Document/RejectDocument?id=222&rejectReason=this is my reject reason

could I then do window.location = href; 然后我可以做window.location = href; and it would call the controller and pass in the correct information? 它将调用控制器并传递正确的信息?

You could use the Url helper to create the right url using the table routes rules. 您可以使用Url帮助程序使用表路由规则创建正确的url。 For sample: 样品:

window.location = '@Url.Action("RejectDocument", "YourController", new { id = 222, rejectReason = "this is my reject reason" })';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM