Next, you'll create a custom view that displays two cards, one with a simple Bootstrap form and another displaying an image, by completing the following steps:
FormsController.cs
to the project's Controllers
folder.Index
action method.Forms
inside the Views
folder.Index.cshtml
, to the newly created Forms
folder.<div class="row"> <h1>Forms</h1> <div class="col-md-3"> <form> <div class="card card-success" style="max-width: 20rem;"> <div class="card-header"> First Panel with simple form </div> <div class="card-block"> <fieldset class="form-group"> <label for="fullName">Full name</label> <input type="text" class="form-control" id="fullName" placeholder="Your full name"> </fieldset> <fieldset class="form-group"> <label for="bio">Full name</label> <textarea class="form-control" id="bio" rows="3"></textarea> </fieldset> </div> <div class="card-footer"> <button type="submit" class="btn btn-danger"> Save</button> </div> </div> </form> </div> <div class="col-md-3"> <div class="card card-primary" style="max-width: 20rem;"> <div class="card-header"> Second card </div> <div class="card-block"> <img src="http://placehold.it/265x150"/> </div> </div> </div> </div>
_Layout.cshtml
file inside the ViewsShared
folder.<li class="nav-item"><a class="nav-link" href="#">Reports</a></li>
<li class="nav-item"><a class="nav-link" asp-controller="Forms" asp-action="Index">Forms</a></li>
asp-*
Tag Helpers were used to specify the controller and action for the <a>
element. When the user clicks on the Forms menu item, they will be shown the form view you created earlier.3.147.77.250