text
stringlengths
0
13.4k
<td>@item.Title</td>
<td>@item.DueAt</td>
</tr>
}
</table>
<div class="panel-footer add-item-form">
<!-- TODO: Add item form -->
</div>
</div>
At the very top of the file, the @model directive tells Razor which model
to expect this view to be bound to. The model is accessed through the
Model property.
Assuming there are any to-do items in Model.Items , the foreach
statement will loop over each to-do item and render a table row ( <tr>
element) containing the item's name and due date. A checkbox is also
rendered that will let the user mark the item as complete.
The layout file
You might be wondering where the rest of the HTML is: what about the
<body> tag, or the header and footer of the page? ASP.NET Core uses a
layout view that defines the base structure that every other view is
rendered inside of. It's stored in Views/Shared/_Layout.cshtml .
29
Create a view
The default ASP.NET Core template includes Bootstrap and jQuery in
this layout file, so you can quickly create a web application. Of course,
you can use your own CSS and JavaScript libraries if you'd like.
Customizing the stylesheet
The default template also includes a stylesheet with some basic CSS
rules. The stylesheet is stored in the wwwroot/css directory. Add a few
new CSS style rules to the bottom of the site.css file:
wwwroot/css/site.css
div.todo-panel {
margin-top: 15px;
}
table tr.done {
text-decoration: line-through;
color: #888;
}
You can use CSS rules like these to completely customize how your
pages look and feel.
ASP.NET Core and Razor can do much more, such as partial views and
server-rendered view components, but a simple layout and view is all
you need for now. The official ASP.NET Core documentation (at
ERROR: type should be string, got "https://docs.asp.net)\tcontains\ta\tnumber\tof\texamples\tif\tyou'd\tlike\tto\tlearn"
more.
30
Add a service class
Add a service class
You've created a model, a view, and a controller. Before you use the
model and view in the controller, you also need to write code that will