You can use the same construct when you wrap your div's inside element like:
@if (ViewBag.Section == "Home")
{
<text><div id="headerfrontPage"></text>
}
else
{
<text><div id="header"></text>
}
Or you use razor syntax @: like
@if (ViewBag.Section == "Home")
{
@:<div id="headerfrontPage">
}
else
{
@:<div id="header">
}
But for your current situation I would prefer Ron Sijm's solution:
@{
var divName = ViewBag.Section == "Home" ? "headerfrontPage" : "header";
}
<div id="@divName">
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…