D
D
Dmitry Ti2015-05-29 16:23:17
css
Dmitry Ti, 2015-05-29 16:23:17

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

1 answer(s)
C
CrazyHorse, 2015-05-29
@demylia

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 question

Ask a Question

731 491 924 answers to any question