1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2026-08-11 16:32:55 +00:00

Ch. 20 View - WorkingWithRazor

This commit is contained in:
wook
2017-04-13 21:41:51 +09:00
parent f22761fe5c
commit a3ef7da060
19 changed files with 540 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
@{
ViewBag.Title = "List";
Layout = null;
}
<h3>This is the /Views/Common/List.cshtml View</h3>
@*@Html.Partial("MyPartial")*@
@Html.Partial("MyStronglyTypedPartial", new [] { "Apple", "Orange", "Pear"})
@Html.Action("TIME")
+32
View File
@@ -0,0 +1,32 @@
@model string[]
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header {
<div class="view">
@foreach (string str in new[] { "Home", "List", "Edit" })
{
@Html.ActionLink(str, str, null, new { style = "margin: 5px" })
}
</div>
}
@section Body {
<div class="view">
This is a list of fruit names:
@foreach (string name in Model)
{
<span><b>@name</b></span>
<p />
}
</div>
}
@section Footer{
<div class="View">
This is the footer
</div>
}
+3
View File
@@ -0,0 +1,3 @@
@model DateTime
<p>The time is: @Model.ToShortTimeString()</p>
@@ -0,0 +1,4 @@
<div>
This is the message from the partial view.
@Html.ActionLink("This is a link to the Index action", "Index")
</div>
@@ -0,0 +1,10 @@
@model IEnumerable<string>
<div>
This is the message from the partial view
<ul>
@foreach (string str in Model)
{
<li>@str</li>
}
</ul>
</div>
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<style type="text/css">
div.layout { background-color: lightgray; }
div.view { border: thin solid black; margin: 10px 0;}
</style>
<title>@ViewBag.Title</title>
</head>
<body>
@RenderSection("Header")
<div class="layout">
This is part of the layout
</div>
@RenderSection("Body")
<div class="layout">
This is part of the layout
</div>
@RenderSection("Footer")
<div class="layout">
This is part of the layout
</div>
@RenderSection("scripts", false)
</body>
</html>
+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="WorkingWithRazor" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>