2
How to put a condition if
within a tag <body>
?
While trying to make:
@if (Request.Path.Substring(Request.Path.LastIndexOf("/") + 1).ToLower() == "default") {
<body class="home"
} else {
<body>
}
It does not perform because it does not have a tag </body>
together. If it were a clause <p></p>
it would work, but as the closing tag </body>
can’t be together he won’t let run.
While trying to make a:
<body @if (Request.Path.Substring(Request.Path.LastIndexOf("/") + 1).ToLower() == "default") { Response.Write("class='home'"); } >
It’s nowhere near working.
Presented the error: "; expected"
– Dorathoto
@Dorathoto Missing a semicolon at the end. I edited the answer.
– Leonel Sanches da Silva