Answer the question
In order to leave comments, you need to log in
In Controller I set one of 5 values in ViewBag.State, how to change the "class" attribute in View depending on ViewBag.State?
In Controller I set one of 5 values in ViewBag.State, how to change class (roughly speaking only 1 of 5 colors) in View depending on ViewBag.State? Now I set the value in the controller, then I check in the view already for the color.
As an option to make ViewBag.Color can?
How is it correct in general?
Answer the question
In order to leave comments, you need to log in
As an option, write an extension method to the Html class that will return the desired css class depending on the State value passed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question