Ive got a mega annoying problem I have a view with:
@{
if(ViewBag.Section == \"Home\")
{
You can use the same construct when you wrap your div's inside element like:
@if (ViewBag.Section == "Home")
{
}
else
{
}
Or you use razor syntax @: like
@if (ViewBag.Section == "Home")
{
@:
}
else
{
@:
}
But for your current situation I would prefer Ron Sijm's solution:
@{
var divName = ViewBag.Section == "Home" ? "headerfrontPage" : "header";
}
- 热议问题