Custom View Code Example
|
<< Click to Display Table of Contents >> Navigation: Web UI & API > Extending UI & API > Adding custom views > Custom View Code Example |
Following is a very simple example of the code files required to add a custom view.
IMPORTANT: The route should follow the format: x-bncs/driver/{viewName}
For example, if your view name is "Home", your controller should be: [Route("x-bncs/driver/Home")]
Controllers/InformationController.cs:
using Microsoft.AspNetCore.Mvc;
namespace BNCS.Core.DriverTest.Controllers
{
[Route("x-bncs/driver/Information")]
public class InformationController : Controller
{
public IActionResult Index()
{
return View();
}
}
}
Views/Information/Index.cshtml:
<link rel="stylesheet" href="~/customcss/styles.css" />
<h2 class="h2">Contact Information</h2>
<button id="askContactBtn">Provide Contact Information</button>
<script src="~/customjs/contact.js"></script>