Skip to content

Commit 75a2b03

Browse files
committed
chore: add razor pages example
1 parent 0ffe165 commit 75a2b03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+23458
-0
lines changed

grid/razor-pages/grid/.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "wwwroot/lib"
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@page
2+
@model AboutModel
3+
@{
4+
ViewData["Title"] = "About";
5+
}
6+
<h2>@ViewData["Title"].</h2>
7+
<h3>@Model.Message</h3>
8+
9+
<p>Use this area to provide additional information.</p>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc.RazorPages;
6+
7+
namespace grid.Pages
8+
{
9+
public class AboutModel : PageModel
10+
{
11+
public string Message { get; set; }
12+
13+
public void OnGet()
14+
{
15+
Message = "Your application description page.";
16+
}
17+
}
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@page
2+
@model ContactModel
3+
@{
4+
ViewData["Title"] = "Contact";
5+
}
6+
<h2>@ViewData["Title"].</h2>
7+
<h3>@Model.Message</h3>
8+
9+
<address>
10+
One Microsoft Way<br />
11+
Redmond, WA 98052-6399<br />
12+
<abbr title="Phone">P:</abbr>
13+
425.555.0100
14+
</address>
15+
16+
<address>
17+
<strong>Support:</strong> <a href="mailto:[email protected]">Support@example.com</a><br />
18+
<strong>Marketing:</strong> <a href="mailto:[email protected]">Marketing@example.com</a>
19+
</address>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc.RazorPages;
6+
7+
namespace grid.Pages
8+
{
9+
public class ContactModel : PageModel
10+
{
11+
public string Message { get; set; }
12+
13+
public void OnGet()
14+
{
15+
Message = "Your contact page.";
16+
}
17+
}
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
23+
</p>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace grid.Pages
9+
{
10+
public class ErrorModel : PageModel
11+
{
12+
public string RequestId { get; set; }
13+
14+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
15+
16+
public void OnGet()
17+
{
18+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home Page";
5+
}
6+
7+
<h1>title</h1>
8+
9+
10+
@(Html.Kendo().Grid<Product>(Model.Data)
11+
.Name("Grid")
12+
.Columns(columns =>
13+
{
14+
columns.Bound(p => p.ProductName).Title("Product Name");
15+
columns.Bound(p => p.UnitPrice).Title("Unit Price").Width(130);
16+
})
17+
.HtmlAttributes(new { style = "height: 550px;" })
18+
.Sortable()
19+
.Scrollable()
20+
.Filterable()
21+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
8+
namespace grid.Pages
9+
{
10+
public class IndexModel : PageModel
11+
{
12+
public List<Product> Data { get; set; } = new List<Product>();
13+
14+
public void OnGet()
15+
{
16+
for (int i = 1; i <= 100; i++)
17+
{
18+
Data.Add(new Product() { ProductName = "product" + i, UnitPrice = i });
19+
}
20+
}
21+
}
22+
23+
public class Product
24+
{
25+
public string ProductName { get; set; }
26+
public decimal UnitPrice { get; set; }
27+
28+
public string Category { get; set; }
29+
}
30+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - grid</title>
7+
8+
<environment include="Development">
9+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
10+
<link rel="stylesheet" href="~/css/site.css" />
11+
12+
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.common.min.css">
13+
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.rtl.min.css">
14+
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.default.min.css">
15+
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.1026/styles/kendo.mobile.all.min.css">
16+
17+
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
18+
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/angular.min.js"></script>
19+
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/jszip.min.js"></script>
20+
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.all.min.js"></script>
21+
<script src="https://kendo.cdn.telerik.com/2017.3.1026/js/kendo.aspnetmvc.min.js"></script>
22+
23+
</environment>
24+
<environment exclude="Development">
25+
</environment>
26+
</head>
27+
<body>
28+
<nav class="navbar navbar-inverse navbar-fixed-top">
29+
<div class="container">
30+
<div class="navbar-header">
31+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
32+
<span class="sr-only">Toggle navigation</span>
33+
<span class="icon-bar"></span>
34+
<span class="icon-bar"></span>
35+
<span class="icon-bar"></span>
36+
</button>
37+
<a asp-page="/Index" class="navbar-brand">grid</a>
38+
</div>
39+
<div class="navbar-collapse collapse">
40+
<ul class="nav navbar-nav">
41+
<li><a asp-page="/Index">Home</a></li>
42+
<li><a asp-page="/About">About</a></li>
43+
<li><a asp-page="/Contact">Contact</a></li>
44+
</ul>
45+
</div>
46+
</div>
47+
</nav>
48+
<div class="container body-content">
49+
@RenderBody()
50+
<hr />
51+
<footer>
52+
<p>&copy; 2017 - grid</p>
53+
</footer>
54+
</div>
55+
56+
<environment include="Development">
57+
@*<script src="~/lib/jquery/dist/jquery.js"></script>
58+
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
59+
<script src="~/js/site.js" asp-append-version="true"></script>*@
60+
</environment>
61+
<environment exclude="Development">
62+
@*<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
63+
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
64+
asp-fallback-test="window.jQuery"
65+
crossorigin="anonymous"
66+
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
67+
</script>
68+
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
69+
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
70+
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
71+
crossorigin="anonymous"
72+
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
73+
</script>
74+
<script src="~/js/site.min.js" asp-append-version="true"></script*@>
75+
</environment>
76+
77+
@RenderSection("Scripts", required: false)
78+
</body>
79+
</html>

0 commit comments

Comments
 (0)