Ajax.Actionlink、部分和 webgrid 问题

发布于 2024-11-06 00:43:52 字数 970 浏览 2 评论 0原文

我有以下问题。

我的网址结构是这样的:

/people/edit/usercode

在我的控制器中,我有以下内容:

    [AcceptVerbs(HttpVerbs.Post)]
    public PartialViewResult LoanRefresh(string id)
    {
        PeopleModel p = new PeopleModel();
        return PartialView("_LoanHistory", p.getPersonLoanHistory(id));

    }

在我看来,我有:

@Ajax.ActionLink("Refresh", "LoanRefresh", new { id = Model.IdentityCode }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "loanHistory", LoadingElementId = "Loading"  }, new { @class = "button" })

当运行 Ajax.ActionLink 时,它会正常返回数据并

 <div id="loanHistory">
    @Html.Partial("_LoanHistory", Model.Loans)
 </div>

更新 div,但 url然后将网络网格上的排序链接更改为:

/People/LoanRefresh/AFU0006?sort=CreatedOn&sortdir=ASC

我需要保留为:

/People/编辑/AFU0006?sort=CreatedOn&sortdir=ASC

任何帮助将不胜感激。

I have the following issue.

My url structure is like this:

/people/edit/usercode

In my controller i have the following:

    [AcceptVerbs(HttpVerbs.Post)]
    public PartialViewResult LoanRefresh(string id)
    {
        PeopleModel p = new PeopleModel();
        return PartialView("_LoanHistory", p.getPersonLoanHistory(id));

    }

In my view i have:

@Ajax.ActionLink("Refresh", "LoanRefresh", new { id = Model.IdentityCode }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "loanHistory", LoadingElementId = "Loading"  }, new { @class = "button" })

and

 <div id="loanHistory">
    @Html.Partial("_LoanHistory", Model.Loans)
 </div>

When run the Ajax.ActionLink it gets the data back ok and it updates the div, but the url of the sort links on the webgrid then change their address to:

/People/LoanRefresh/AFU0006?sort=CreatedOn&sortdir=ASC

i need to stay as:

/People/Edit/AFU0006?sort=CreatedOn&sortdir=ASC

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺孤伤于心 2024-11-13 00:43:52

@Nick,那是因为您的操作名称是 LoanRefresh 而不是 Refresh。为此,您可能需要执行一些路由,甚至将 LoanRefresh 结果重定向到名为 Refresh 的操作。

Well @Nick, that's because your action name is LoanRefresh and not Refresh. To do that you will probably have to do some routing or even redirect your LoanRefresh results to an action named Refresh.

尘曦 2024-11-13 00:43:52

尝试将 ajaxUpdateContainerId 设置为分部视图中指定的对象,而不是最初调用分部视图的视图中的对象。然后排序 URL 应该可以正常工作。

Try setting ajaxUpdateContainerId to an object that is specified in the partial view, rather than an object in the view from which the partial view is originally called. The sort URLs should work correctly then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文