Ajax.Actionlink, partial and webgrid issue

≯℡__Kan透↙ 提交于 2019-12-12 05:58:26

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/5931869/ajax-actionlink-partial-and-webgrid-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!