I’m using MVC3 and Spark.
I need to add a class to a LI if a certain ViewBag element is set to X.
<li id="menu-home" class="active?{ViewBag.Active=='home'}" >${Html.ActionLink("Home", "Index", "Site")}</li>
Like the above. This doesnt work, however wondering if there is a way to approach this?
Here are the steps I took and it worked for me:
Spark.Web.Mvc3NuGet package.Change the
Indexaction ofHomeControllerto look like this:Rename
~/Views/Home/Index.cshtmlto~/Views/Home/Index.sparkand make it look like this:Run the project
The generated HTML is:
Remark: Everytime I see someone using ViewBag instead of strongly typed views with view models I feel in the obligation to point this as a bad practice.