title: Ajax request to fetch partial view
body: <p>I have my main view like this:</p>
  
  <p>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %></p>
  
  <p>
      Index
  
  </p>
  
  <pre><code>&lt;script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;h2&gt;
      Index&lt;/h2&gt;
  
  &lt;script type="text/javascript"&gt;
      $(function() {
          $('#mylink').click(function() {
              $('#resultpartial1').load(this.href);
              return false;
          });
      });
  
      $(function() {
          $('#mysecondlink').click(function() {
              $('#resultpartial1').load(this.href, { id: 123 });
              return false;
          });
      });
  &lt;/script&gt;
  
  &lt;%= Html.ActionLink("click me","Partial1","Foo",new MyViewModel { Foo = "123" , Bar="456" },new { id = "mylink" }) %&gt;
  &lt;%= Html.ActionLink("click me second link","Partial2", "Foo", new { id = "123" }, new { id = "mysecondlink" }
  </code></pre>
  
  <p>) %>
      
  </p>
  
  <p>and controller like this:</p>
  
  <pre><code>public class FooController : Controller
  {
      //
      // GET: /Foo/
  
      public ActionResult Index()
      {
          return View();
      }
  
      public ActionResult Partial1(string id)
      {
          // TODO: use the id to fetch the model from somewhere
          MyViewModel model = new MyViewModel { Bar = "a", Foo = "1" };
          return View(model);
      }
  
      public ActionResult Partial2(string id)
      {
          // TODO: use the id to fetch the model from somewhere
          MyViewModel model = new MyViewModel { Bar = "b", Foo = "2" };
          return View(model);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and partial views like this :</p>
  
  <p>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %></p>
  
  Foo: 
  
  Bar: 
  
  <p>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %></p>
  
  Foo: 
  
  Bar: 
  
  <p>I am always getting values set by controller actions. I want to set values in view and pass to partial view. How can I do this ?</p>