9.1: NoteEdit View
Last updated
Last updated
Edit
ViewNow we create the physical view for the NoteEdit
model.
Still in the NoteController.cs
file, right click on the Edit(int id)
method
Add a view as below:
Edit
Post MethodBack in NoteController.cs
, build an overloaded Edit
ActionResult under the Edit(int id)
method:
Add some validation similar to the ActionResult Create
to make sure the NoteId
matches:
Continue to build out the method, displaying a message to the user with the result of their actions:
NoteId
from the Edit ViewGo to ElevenNote.Web -> Views -> Note -> Edit.cshtml
Delete lines 18-24, we don't need to see the NoteId
, and it should not be editable.
We will add a reference to this code, but make it hidden.
Add this line of code (starting with @Html.HiddenFor...
) in place of the lines we deleted:
If you run from the Edit.cshtml
file, you will get an error because the URL goes to /Note/Edit but not to a specific note id.
Change the URL to remove /Edit to get to the index view which lists all the notes.
Next, we'll add the ability to delete a note.
Run the app and make sure you can edit a note, if so,