I can not seem to get this to work.
@if (isReal)
{
@section Navigation{
@{Html.RenderPartial("NavigationForInput");}
}
}
that doesn't work because it says "once inside code you dont' need @ blah blah blah"
but, when I remove the @ from in front of section, it wants to use section as a type variable.
how can I only show that section conditionally?
Depending if your Layout has an alternative for undefined sections or not, you could just reverse the @if
and @section
@section Navigation{
{
@if (isReal)
@{Html.RenderPartial("NavigationForInput");}
}
}
If you just want to leave out the nav, this should be fine, but it won't work if you are using IsSectionDefined("Navigation") in your layout, as it will always return true.
The idea:
@if (Condition)
{
<text>
@section SectionName {
}
</text>
}
Here is the code:
@if (isReal)
{
<text>
@section Navigation{
@{Html.RenderPartial("NavigationForInput");}
}
</text>
}
Happy coding!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With