Reputation: 3177
So I found this really nice bootstrap slider that I would like to use in my asp.net project's index html page.
For some reason if I am trying to put straight into index.html:
<!-- Half Page Image Background Carousel Header -->
<div id="myCarousel" class="carousel slide">
... some data related to slider
</div>
it just simply won't display properly, however if I will cut this part and paste into _Layout.html
right before:
// right before this div
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
it works perfectly fine. For some reason slider doesn't like to be inside another div, when it's on its own, it works great.
But obviously since _Layout.html
is shared between pages I don't want have slider to be shown for every page, so I was wondering what would be the best way to solve it.
Upvotes: 1
Views: 615
Reputation: 21477
Not sure why you have problems with it being in a div (most likely you have a style on the container class, or body-content class that is interfering), however, you can create your own custom section in layout, that isn't required and only put that section in the page you want.
Put this in _layout.html where you want the slider to go:
@RenderSection("slider", required: false)
and put this in your page:
@section slider {
Your slider html here
}
Upvotes: 1
Reputation: 145
not really sure why it wont work inside a div but what about using two _Layout.html ?
one for the site that needs the slider and the second for all other sites.
Upvotes: 0