8.1: Detail View
Create the Detail View
In order to physically see the NoteDetail
model on our webpage, we need to create a view for it.
Open
NoteController.cs
The error is gone since we added the
GetNoteById()
method inNoteService.cs
Right click on the
Details()
method and add a viewFill it out like this:
ActionLinks
In the
Details.cshtml
file that was created, change theActionLink
s at the bottom to:</div> <p> @Html.ActionLink("Edit", "Edit", new { id = Model.NoteId }) | @Html.ActionLink("Back to List", "Index") </p>
Go to Views -> Notes -> Index.cshtml
Change the
ActionLink
s at the bottom to:</td> <td> @Html.ActionLink("Edit", "Edit", new { id=item.NoteId }) | @Html.ActionLink("Details", "Details", new { id=item.NoteId }) | @Html.ActionLink("Delete", "Delete", new { id=item.NoteId }) </td> </tr> }
These anonymous classes inside the
ActionResult
will communicate to theNoteController
and select the appropriate Note.Run the app and go to the details view on one of the notes:
Do you see that URL localhost:59641/Note/Details/4? Next, we'll cover the components of it.
Last updated