How to use data templates in ASP.NET razor syntax -


i working on asp.net project , want make page have :

enter image description here

i want put images in previous picture in data templates , want show pages numbers in way .... there article or tutorial can me perform ... because i'm beginner in field ....

assume view models:

public class projectvm {   public string imageurl { get; set; }   public string projectname { get; set; } } public class indexvm {   // nuget> install-package pagedlist   public ipagedlist<projectvm> projects { get; set; } } 

then controller:

public class homecontroller : controller {   public actionresult index(int32 page = 1)   {     indexvm model = new indexvm     {       projects = projectservice.getprojects().topagedlist(page, 6)     };     return view(model);   } } 

then views:

~/views/shared/displaytemplates/projectvm.cshtml

@model projectvm @* or display it... *@ <div class="span4">   <img src="@model.imageurl" />   <p>@model.name</p> </div> 

~/views/home/index.cshtml

@mode indexvm @* or display it... *@ <div class="content">   <section>     <div class="title">       <h1>all projects</h1>       <div class="paging">         @html.pagedlistpager((ipagedlist)model.projects, page => url.action("index", new { page }))       </div>    @html.displayfor(x => x.projects) </div> 

example project found on github


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -