html - MVC : Not render css class for certain view? -


i new css , don't have knowledge it.

i have mvc application uses theme built based on bootstrap.

and in _layout view have code

<div class="container body-content">     @html.partial("_alerts")     @renderbody()            <hr />     <footer>         <p>&copy; @datetime.now.year -myapp</p>     </footer> </div> 

i'm guessing view wrapped container body-content class.

which fine, because web app's content not displayed in full width stretched.

but home page(landing page) let's say. has slider , because of container body-content class not being shown in full width.

this how home page starts

<div class="fullwidthbanner-container" style="overflow:visible">     <div class="fullwidthbanner">         <ul>             <!-- slide 1 -->             <li data-transition="slideright">    ...    ...    ... </div> 

and here class fullwidthbanner-container

.fullwidthbanner-container {     width: 100%!important;     max-height: 550px!important;     position: relative;     padding: 0;     overflow: hidden!important;     margin:0px 0 0px; } 

how make home page not wrapped aroundcontainer body-content?

please let me know if have provide more details.

you can try following:

in _layout.cshtml add code block before html:

@{      string classtoset = "";      string action = viewcontext.routedata.values["action"] string;      string controller = viewcontext.routedata.values["controller"] string;       //you might need check nulls       if (!(action == "index" && controller == "home"))      {          classtoset = "container body-content";      } } 

you can set class using razor:

<div class="@classtoset">      @html.partial("_alerts")      @renderbody()             <hr />     <footer>          <p>&copy; @datetime.now.year -myapp</p>     </footer> </div> 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -