title: MVC Paging with partial views
body: <p>I'm a relatively new MVC user, and am having difficulty getting paging to work properly in MVC. </p>
  
  <p>Basically I have a load of search results which are rendered in a partial view (using the begin form method like so): </p>
  
  <pre><code>using (Ajax.BeginForm("Search", "Home", new AjaxOptions
  {
      HttpMethod = "GET",
      InsertionMode = InsertionMode.Replace,
      UpdateTargetId = "searchResults",
  }))
  {
      &lt;input type="text" name="searchString" /&gt;
      &lt;input type="submit" value="Search" /&gt;
  }
  </code></pre>
  
  <p>And the partial view is rendered thusly:</p>
  
  <pre><code>@foreach (var item in @Model)
  </code></pre>
  
  <p>{</p>
  
  <pre><code>&lt;li&gt;@Html.ActionLink(item.Name, "Result/" + item.Id, "Result")&lt;/li&gt;
  
  }
  
  @{if(ViewBag.HasPrevious)
      {
          @Html.ActionLink("&lt;&lt;", "Search", new { searchString = ViewBag.query, page = ViewBag.CurrentPage-1 })
      }
  }
  
  @{if(ViewBag.HasNext)
      {
          @Html.ActionLink("&gt;&gt;", "Search", new {  searchString = ViewBag.query, page = ViewBag.CurrentPage+1 })
      }
  }
  </code></pre>
  
  <p>My problem is that the >> or &lt;&lt; links simply create a blank page with the list of results on it, and doesn't persist the markup of the 'top' index page. </p>
  
  <p>Does anyone have any ideas re this.</p>
  
  <p>NB am new to this site, and I will upvote any answers.</p>