Search code examples
.netreserved-words

How do I add a class dynamically when using .NET


I have a top nav and I'm in a .NET framework. I want to check the value of a variable and add an active class if need be. I'm not a .NET guy, so I'm scratching my head over this since I have:

<li @if(ViewBag.Area == "account"){ class="active"}><a href="#">My Account</a></li>

But, as I'm sure all you .NET folks are nodding about right now, that doesn't work since class is reserved.

How would I do this?

Thanks!


Solution

  • try

    <li @if(ViewBag.Area == "account"){ <text>class="active"</text>}>