User1520731567 posted
Hi ArunBerlin,
If you want to implement side navigation,you could
only use html+css+js,for example:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: "Lato", sans-serif;
}
.sidenav {
height: 100%;
width: 0;
;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a:hover {
color: #f1f1f1;
}
.sidenav .closebtn {
;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
</style>
</head>
<body>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<h2>Animated Sidenav Example</h2>
<p>Click on the element below to open the side navigation menu.</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ open</span>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
</body>
</html>
or create a collapsible HTML sidebar navigationusing Bootstrap 4 with some CSS and jQuery:
https://bootstrapious.com/p/bootstrap-sidebar
Many demos in here:
https://bootsnipp.com/tags/sidebar/3
Call the HTML page on Multiple Razor view Pages
I recommend to place your sidebar in Layout.cshtml.
(Also,You could choose to code sidebar as a Partial View, and then call it in
Layout.cshtml.)
In this case, all Razor pages that reference the Layout view can display sidebar.
If you only want a few special razor views to show sidebar,you could define
ViewBag in their own actions:
ViewBag.PreferredSidebar = "default";//ViewBag.PreferredSidebar = "default2"
and later you can work with this value in Layout.cshtml:
@if(ViewBag.PreferredSidebar == "default"||ViewBag.PreferredSidebar == "default2")
{
@Html.Partial("SidebarDefault")
}
Best Regards.
Yuki Tao