如何在asp.net MVC中创建Ajax链接?

时间:2014-03-20 12:10:33

标签: c# asp.net-mvc

我是asp.net MVC的新手,在app中我需要通过ajax调用操作和更新容器div,我该怎么办?

<div id="updateContainer">
</div>

@foreach(string str in new[] {"All", "Joe", "Jane", "Bob"}){
  <div>
    @Ajax.ActionLink(str,"ApprointmentData", new {id= str })
  </div>
 }

2 个答案:

答案 0 :(得分:3)

你应该使用ajax选项

@foreach(string str in new[] {"All", "Joe", "Jane", "Bob"}){
  <div>
    @Ajax.ActionLink(str,"ApprointmentData", new {id= str },
      new AjaxOptions{ 
            UpdateTargetId="updateContainer",
      }
    )
  </div>
 }

答案 1 :(得分:0)

@Ajax.ActionLink("Link Text", "MyAction", "MyController", new { month = "January"},new AjaxOptions{UpdateTargetID="YourUID here"}