English 中文(简体)
如何在Ajax的点击上复述多处部分。 行动联系
原标题:How to refresh multiple partialview on click of Ajax.Actionlink

I am using multiple partial views on my View. on the left-hand side. I have some link button.

In middle, I have 2 partial views let us suppose Up and Down I m able to update the Up partial view now I want to update Down partial view on the click of the same link button

I am able to send only one UpdateTargetID in Ajax.ActionLink button but I want to update 2 Partial views on the click of the same button.

1) Is there any way I can pass more than one UpdateTargetID in Ajax.ActionLink or 2) I can return Multiple partial views in Home Controller or any other way as you suggested Please reply to me

Thanks, Everyone for replying Let me tell you what I have done in order to refresh multiple partial view on a single click This is the Action Link which I m using to click on Here I m using a OnSucess Function of this Action link in order to update, This Action link is on a partial view

                 <%= Ajax.ActionLink("Select", "Employee", new { Id = Employee.EmployeeID }, new AjaxOptions { UpdateTargetId = "EmployeeDiv", HttpMethod = "Post", OnSuccess = "function(){EmployeeHistory(-2," + Employee.EmployeeID.ToString() + ");}" })%>

这是我从部分观点呼吁的 j。

 function  EmployeeHistory(EmployeeID) {
    var url =  <%= Url.Action("PartialviewAction", "ControllerName") %> 
    $( #PartialviewDiv1 ).load(url, { Id: EmployeeID });
    var url1 =  <%= Url.Action("PartialviewAction", "ControllerName") %> 
    $( #PartialviewDiv2 ).load(url1, { Id: EmployeeID });

}

这两点是指数,我想更新。

        <div id="Paritalview div1"><% Html.RenderPartial("PartialViewname1"); %></div>
        <div id="Paritalview div2"><% Html.RenderPartial("PartialViewname2"); %></div>
最佳回答

是的,没有使用<代码>Ajax.ActionLink。

海事组织,MS Ajax图书馆,与网络表格一样,被捆绑。

保持其简单性——使用jQuery,然后完全控制:

$(function() {
   $( #somelink ).click(function(e) {
      e.preventDefault();

      $.get( /controller/action1 , function(data) {
         $( #up ).html(data);
      });

      $.get( /controller/action2 , function(data) {
         $( #down ).html(data);
      });
   });
});

然而,由于你对这两个小组进行了更新,我建议从自己的部分角度总结这两个小组,然后采用单一行动方法,因此,你只需要1个警钟。

<><>Edit>/strong>

如@FelixM提到,你应使用<代码>Url.Action或Url.RouteUrl,为非洲宇宙航空研究开发机构电话生成URL,这样,如果您的路线发生变化,你无需提交书面材料,例如:

.get(@Url.Action(主计长, 行动1) ,职能(数据)

get(@Url.RouteUrl ( SomeNamedRoute ) ,Function(data)

如果你把这一文字放在外部档案中,那么你就不得不使用一种技术,在主眼中确定这个词,然后从外部变量读。

这些技术包括 Java本变数、隐蔽的领域、将URL作为参数运行等。

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签