Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think your idea is good enough.</p> <p>Just put all the elements you want from each page into differents divs. Then give the div a class or id attribute that is easily identifiable, such as:</p> <pre><code>&lt;div id="page1" class="divpage"&gt; page 1 html here &lt;/div&gt; &lt;div id="page2" class="divpage"&gt; page 2 html here &lt;/div&gt; </code></pre> <p>etc</p> <p>The jQuery code would look like this:</p> <pre><code>$("#page1").show(); $(".divpage").hide(); //this hides all other divs </code></pre> <p><strong>Edit:</strong></p> <p>To do this dynamically, creat a strongly-typed view associated to your list of results. The header of the view should be something like:</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;IEnumerable&lt;Result&gt;&gt;" %&gt; </code></pre> <p>With "result" being your class:</p> <pre><code>public class Result { int score {get;set;} string data {get;set;} } </code></pre> <p>Then in your view, you put this:</p> <pre><code>&lt;%int resultsPerPage = 10; int currentResults = 0; int numPage=0; foreach(var item in Model) { if (currentResults==0) Response.Write("&lt;div id=\"page"+numPage+"\" class=\"divpage\"&gt;"); %&gt; &lt;%=item.score.ToString()%&gt; &lt;%=item.data%&gt; &lt;%currentResults++; if (currentResults&gt;resultsPerPage) { numPage++; currentResults=0; Response.Write("&lt;/div&gt;"); } }%&gt; &lt;%if (currentResults!=0) Response.Write("&lt;/div&gt;");%&gt; </code></pre> <p>Then for your buttons:</p> <pre><code>&lt;%for (int i=0;i&lt;numPage;i++) { %&gt; &lt;a href="" onclick="showPage('&lt;%=i%&gt;');return false;"&gt;Page &lt;%=i%&gt;&lt;/a&gt; &lt;%}%&gt; &lt;script type="text/javascript"&gt; function showPage(num) { $("#page"+num).show(); $(".divpage").hide(); } &lt;/script&gt; </code></pre> <p>Finally, in your controller:</p> <pre><code>public ActionResult ShowResults() { List&lt;Result&gt; results = getResultsOrdererdByScoreFunction(); return View(results); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload