Skip to content

Commit b282206

Browse files
19th commit
PagedList tool usage
1 parent 52a22ab commit b282206

File tree

6 files changed

+191
-9
lines changed

6 files changed

+191
-9
lines changed

MvcCV/Content/PagedList.css

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
.pagination {
2+
display: inline-block;
3+
padding-left: 0;
4+
margin: 20px 0;
5+
border-radius: 4px;
6+
}
7+
8+
.pagination > li {
9+
display: inline;
10+
}
11+
12+
.pagination > li > a,
13+
.pagination > li > span {
14+
position: relative;
15+
float: left;
16+
padding: 6px 12px;
17+
margin-left: -1px;
18+
line-height: 1.428571429;
19+
text-decoration: none;
20+
background-color: #ffffff;
21+
border: 1px solid #dddddd;
22+
}
23+
24+
.pagination > li:first-child > a,
25+
.pagination > li:first-child > span {
26+
margin-left: 0;
27+
border-bottom-left-radius: 4px;
28+
border-top-left-radius: 4px;
29+
}
30+
31+
.pagination > li:last-child > a,
32+
.pagination > li:last-child > span {
33+
border-top-right-radius: 4px;
34+
border-bottom-right-radius: 4px;
35+
}
36+
37+
.pagination > li > a:hover,
38+
.pagination > li > span:hover,
39+
.pagination > li > a:focus,
40+
.pagination > li > span:focus {
41+
background-color: #eeeeee;
42+
}
43+
44+
.pagination > .active > a,
45+
.pagination > .active > span,
46+
.pagination > .active > a:hover,
47+
.pagination > .active > span:hover,
48+
.pagination > .active > a:focus,
49+
.pagination > .active > span:focus {
50+
z-index: 2;
51+
color: #ffffff;
52+
cursor: default;
53+
background-color: #428bca;
54+
border-color: #428bca;
55+
}
56+
57+
.pagination > .disabled > span,
58+
.pagination > .disabled > a,
59+
.pagination > .disabled > a:hover,
60+
.pagination > .disabled > a:focus {
61+
color: #999999;
62+
cursor: not-allowed;
63+
background-color: #ffffff;
64+
border-color: #dddddd;
65+
}
66+
67+
.pagination-lg > li > a,
68+
.pagination-lg > li > span {
69+
padding: 10px 16px;
70+
font-size: 18px;
71+
}
72+
73+
.pagination-lg > li:first-child > a,
74+
.pagination-lg > li:first-child > span {
75+
border-bottom-left-radius: 6px;
76+
border-top-left-radius: 6px;
77+
}
78+
79+
.pagination-lg > li:last-child > a,
80+
.pagination-lg > li:last-child > span {
81+
border-top-right-radius: 6px;
82+
border-bottom-right-radius: 6px;
83+
}
84+
85+
.pagination-sm > li > a,
86+
.pagination-sm > li > span {
87+
padding: 5px 10px;
88+
font-size: 12px;
89+
}
90+
91+
.pagination-sm > li:first-child > a,
92+
.pagination-sm > li:first-child > span {
93+
border-bottom-left-radius: 3px;
94+
border-top-left-radius: 3px;
95+
}
96+
97+
.pagination-sm > li:last-child > a,
98+
.pagination-sm > li:last-child > span {
99+
border-top-right-radius: 3px;
100+
border-bottom-right-radius: 3px;
101+
}
102+
103+
.pager {
104+
padding-left: 0;
105+
margin: 20px 0;
106+
text-align: center;
107+
list-style: none;
108+
}
109+
110+
.pager:before,
111+
.pager:after {
112+
display: table;
113+
content: " ";
114+
}
115+
116+
.pager:after {
117+
clear: both;
118+
}
119+
120+
.pager:before,
121+
.pager:after {
122+
display: table;
123+
content: " ";
124+
}
125+
126+
.pager:after {
127+
clear: both;
128+
}
129+
130+
.pager li {
131+
display: inline;
132+
}
133+
134+
.pager li > a,
135+
.pager li > span {
136+
display: inline-block;
137+
padding: 5px 14px;
138+
background-color: #ffffff;
139+
border: 1px solid #dddddd;
140+
border-radius: 15px;
141+
}
142+
143+
.pager li > a:hover,
144+
.pager li > a:focus {
145+
text-decoration: none;
146+
background-color: #eeeeee;
147+
}
148+
149+
.pager .next > a,
150+
.pager .next > span {
151+
float: right;
152+
}
153+
154+
.pager .previous > a,
155+
.pager .previous > span {
156+
float: left;
157+
}
158+
159+
.pager .disabled > a,
160+
.pager .disabled > a:hover,
161+
.pager .disabled > a:focus,
162+
.pager .disabled > span {
163+
color: #999999;
164+
cursor: not-allowed;
165+
background-color: #ffffff;
166+
}

MvcCV/Controllers/SkillsController.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
using System.Web.Mvc;
66
using MvcCV.Models.Entity;
77
using MvcCV.Models.Sınıf;
8+
using PagedList;
9+
using PagedList.Mvc;
810

911
namespace MvcCV.Controllers
1012
{
1113
public class SkillsController : Controller
1214
{
1315
// GET: Skills
1416
DbMvcCvEntities db = new DbMvcCvEntities();
15-
public ActionResult Index()
17+
public ActionResult Index(int page = 1)
1618
{
17-
Class1 cs = new Class1();
18-
cs.Deger4 = db.TBLSKILLS.ToList();
19-
return View(cs);
19+
// Class1 cs = new Class1();
20+
var degerler = db.TBLSKILLS.ToList().ToPagedList(page, 3);
21+
return View(degerler);
2022
}
2123
[HttpGet]
2224
public ActionResult NewSkill()

MvcCV/MvcCV.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.CSharp" />
55+
<Reference Include="PagedList, Version=1.17.0.0, Culture=neutral, PublicKeyToken=abbb863e9397c5e1, processorArchitecture=MSIL">
56+
<HintPath>..\packages\PagedList.1.17.0.0\lib\net40\PagedList.dll</HintPath>
57+
</Reference>
58+
<Reference Include="PagedList.Mvc, Version=4.5.0.0, Culture=neutral, PublicKeyToken=abbb863e9397c5e1, processorArchitecture=MSIL">
59+
<HintPath>..\packages\PagedList.Mvc.4.5.0.0\lib\net40\PagedList.Mvc.dll</HintPath>
60+
</Reference>
5561
<Reference Include="System" />
5662
<Reference Include="System.Data" />
5763
<Reference Include="System.Drawing" />
@@ -180,6 +186,7 @@
180186
<Content Include="Content\bootstrap-theme.min.css" />
181187
<Content Include="Content\bootstrap.css" />
182188
<Content Include="Content\bootstrap.min.css" />
189+
<Content Include="Content\PagedList.css" />
183190
<Content Include="favicon.ico" />
184191
<Content Include="fonts\glyphicons-halflings-regular.svg" />
185192
<Content Include="Global.asax" />

MvcCV/Views/Skills/Index.cshtml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
@model MvcCV.Models.Sınıf.Class1
1+
@using MvcCV.Models.Entity
2+
@using PagedList
3+
@using PagedList.Mvc
4+
@model PagedList.IPagedList<TBLSKILLS>
25
@{
36
ViewBag.Title = "Index";
47
Layout = "~/Views/Shared/_MainLayout.cshtml";
@@ -16,17 +19,19 @@
1619
</tr>
1720
</thead>
1821
<tbody>
19-
@foreach (var x in Model.Deger4)
22+
@foreach (var x in Model)
2023
{
2124
<tr>
2225
<th>@x.ID</th>
2326
<td>@x.SKILL</td>
2427
<td><a href="/Skills/DeleteSkill/@x.ID" class="btn btn-danger">Delete</a></td>
2528
<td><a href="/Skills/BringSkill/@x.ID" class="btn btn-success">Update</a></td>
26-
<td>@Html.ActionLink("Delete Button", "DeleteSkill", new { id=x.ID}, new { @class="btn btn-warning",onclick="return confirm('Do you want to delete now?')"})</td>
29+
<td>@Html.ActionLink("Delete Button", "DeleteSkill", new { id = x.ID }, new { @class = "btn btn-warning", onclick = "return confirm('Do you want to delete now?')" })</td>
2730
</tr>
2831
}
2932
</tbody>
3033
</table>
34+
35+
@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page }))
3136
<a href="/Skills/NewSkill/" class="btn btn-info">Add New Skill</a>
3237

MvcCV/Web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
</dependentAssembly>
4343
<dependentAssembly>
4444
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
45-
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
45+
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
4646
</dependentAssembly>
4747
<dependentAssembly>
4848
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
49-
<bindingRedirect oldVersion="1.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
49+
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
5050
</dependentAssembly>
5151
</assemblyBinding>
5252
</runtime>

MvcCV/packages.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
1515
<package id="Modernizr" version="2.8.3" targetFramework="net461" />
1616
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
17+
<package id="PagedList" version="1.17.0.0" targetFramework="net461" />
18+
<package id="PagedList.Mvc" version="4.5.0.0" targetFramework="net461" />
1719
<package id="WebGrease" version="1.6.0" targetFramework="net461" />
1820
</packages>

0 commit comments

Comments
 (0)