Last post Apr 27, 2020 04:01 PM by coreysan
Apr 24, 2020 12:07 AM|coreysan|LINK
I started learning Core 2.1, and made use of the partial view for Cookies Consent. Things went well.
Then I changed the bootstrap file from v. 3 to v.4, and the consent message looks wonky. The navbar
collapses by default, the button is now a tiny 4 pixel barline, and the entire navbar is unformatted.
Has anyone come across this and fixed it? What did you do?
I'd be grateful for any advice on how to fix this. All my code is auto-generated. Only bootstrap changed.
Apr 24, 2020 08:42 AM|Rena Ni|LINK
You could create a project and see the difference between bootstrap v4 and v3,change like below:
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">TestProject</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<div class="navbar-collapse collapse">
<ul class="navbar-nav flex-grow-1">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
<partial name="_CookieConsentPartial" />
<div class="container body-content">
<p>© 2020 - TestProject</p>
Apr 24, 2020 10:45 PM|coreysan|LINK
Hi Rena! Thanks for working with me on this.
I copied your code exactly, and ran with borrstrap 3.0.3, and also for 4.3.1.
Both look awful.
Version 3 shows the consent dialog and buttons at the top, but then corrupts the nav bar by inserting a little gray bar about 4-5 pixels high.
Version 4 is worse. It doesn't show any dialog because the default project slideshow covers it up. It also shows the tiny gray bar.
Maybe if I just redesign the whole thing? What would you do?
Apr 27, 2020 09:40 AM|Rena Ni|LINK
For asp.net core 2.1,it uses bootstrap v3.And for asp.net core 2.2,it uses bootstrap v4.
I think the fastest way is to create a project with asp.net core 2.2.Then copy the whole Index.cshtml and _Layout.cshtml.And for 2.2,it does not contain the _CookieConsentPartial in Layout,you could add by yourself.
Apr 27, 2020 04:01 PM|coreysan|LINK
Thanks so much for your help! This discussion motivated me to look for alternate code, and I found the right layout in MSDN.
It's just a reduced partial view and works much, much better!
Thanks for pushing me!