Note that there are some explanatory texts on larger screens.

plurals
  1. PORAZOR MVC3: Partial View to Reuse
    text
    copied!<p>I have two entities – PopularTutorial and Blog. This data need to be displayed in homepage view as listed below. The key point is that the “PopularTutorial” should be reused in other views and Bloglist also may be reused in other views. There is a manual paging option in the “PopularTutorial” section. When page 1 is clicked, first 3 popular tutorials will be listed . When page 2 is clicked tutorials 4 to 6 will be listed.</p> <p>I know “partial view” is the way to go. When I searched I came across methods that involve jQuery and JSON. I am wondering whether this can be done (in RAZOR) without explicit use of jQuery and JSON. </p> <p>Could you please help me for this in RAOZR?</p> <p>To be honest – I am doing this as a step before learning AJAX in MVC. So my next attempt will be to ajaxify it. It would be great if you can provide an answer that will work in ajax way also.</p> <p><img src="https://i.stack.imgur.com/UkNs1.gif" alt="enter image description here"></p> <pre><code>public class PopularTutorial { public int ID { get; set; } public int NumberOfReads { get; set; } public string Title { get; set; } } public class Blog { public int ID { get; set; } public string Head { get; set; } public string PostBy { get; set; } public string Content { get; set; } } namespace MyArticleSummaryTEST.Controllers { public class HomePageViewModel { public IEnumerable&lt;Blog&gt; BlogList { get; set; } public IEnumerable&lt;PopularTutorial&gt; PopularBlogs { get; set; } } public class ArticleController : Controller { private IEnumerable&lt;PopularTutorial&gt; GetPopularBlogs() { List&lt;PopularTutorial&gt; popularArticleList = new List&lt;PopularTutorial&gt;() { new PopularTutorial{ID=17,Title="Test1",NumberOfReads=1050}, new PopularTutorial{ID=18,Title="Test2",NumberOfReads=5550}, new PopularTutorial{ID=19,Title="Test3",NumberOfReads=3338} }; return popularArticleList; } private IEnumerable&lt;Blog&gt; GetAllBlogEntries() { List&lt;Blog&gt; articleSummaryList = new List&lt;Blog&gt;() { new Blog {ID=1,Head="Introduction to MVC",PostBy="Lijo", Content="This is a ..."}, new Blog {ID=2,Head="jQuery Hidden Gems",PostBy="Lijo", Content="This is a ..."}, new Blog {ID=3,Head="Webforms Intenals",PostBy="Lijo", Content="This is a ..."} }; return articleSummaryList; } } } </code></pre> <p>READING:</p> <ol> <li><p><a href="http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid" rel="nofollow noreferrer">http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid</a></p></li> <li><p><a href="https://stackoverflow.com/questions/567403/asp-net-mvc-partial-views-and-redirecting">ASP.NET MVC partial views and redirecting</a></p></li> <li><p>@Html.Partial() Vs @Html.Action() - MVC Razor <a href="http://pratapreddypilaka.blogspot.in/2011/11/htmlpartial-vs-htmlaction-mvc-razor.html" rel="nofollow noreferrer">http://pratapreddypilaka.blogspot.in/2011/11/htmlpartial-vs-htmlaction-mvc-razor.html</a></p></li> <li><p><a href="https://stackoverflow.com/questions/4941630/to-webgrid-or-not-to-webgrid-what-is-the-answer">To WebGrid or not to WebGrid...what is the answer?</a></p></li> <li><p><a href="http://mvccontrib.codeplex.com/" rel="nofollow noreferrer">http://mvccontrib.codeplex.com/</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5161380/how-do-i-specify-different-layouts-in-the-asp-net-mvc-3-razor-viewstart-file">How do I specify different Layouts in the ASP.NET MVC 3 razor ViewStart file?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/1205861/asp-net-mvc-returning-to-host-controller-when-using-partial-views">Asp.net MVC - Returning to &quot;host&quot; controller when using partial views</a></p></li> <li><p><a href="https://stackoverflow.com/questions/1948230/how-do-i-render-an-alternate-child-view-in-mvc">How do I render an alternate child view in MVC?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/6157348/when-do-i-use-view-models-partials-templates-and-handle-child-bindings-with-mv">When do I use View Models, Partials, Templates and handle child bindings with MVC 3</a></p></li> <li><p><a href="https://stackoverflow.com/questions/4195440/mvc-3-texbox-in-webgrid-razor">Mvc 3 texbox in webgrid (razor)</a></p></li> <li><p><a href="https://stackoverflow.com/questions/4306683/how-to-make-a-mvc-3-webgrid-with-checkbox-column">How to make a MVC 3 Webgrid with checkbox column?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/6167903/using-data-in-a-html-actionlink-inside-a-webgrid-column-not-possible">Using data in a HTML.ActionLink inside a WebGrid.column, not possible?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5161203/htmlhelper-inside-webgrid">htmlhelper inside webgrid</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5732736/razor-nested-webgrid">Razor Nested WebGrid</a></p></li> <li><p><a href="https://stackoverflow.com/questions/7866051/conditionally-display-an-image-in-webgrid-mvc-3">Conditionally display an image in webgrid - mvc 3</a></p></li> <li><p><a href="https://stackoverflow.com/questions/4714384/how-to-hide-header-on-mvc3-webgrid">How to hide header on MVC3 WebGrid</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5160551/hide-webgrid-column-based-on-user-role-mvc-3">How can I hide a WebGrid column based on the current user&#39;s role?</a></p></li> <li><p><a href="https://stackoverflow.com/questions/5409749/is-the-mvc-webgrid-open-source">Is the MVC WebGrid Open Source?</a></p></li> </ol> <hr>
 

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