how to change background color for different user/condition inside html tag in .net with Model value

Viewed 32

I have existing web application built on .NET Framework 4.5.2, we have css file which affects all views that make use of a main layout (_Layout.vbhtml) and (_XNavigational.vbhtml) for Navigational panel. I want different background colors depending on the user type in the (ul) section

Note: UserType can be obtained from Model.

class="x-navigation" x-Navigation is already part of css file where background has been set already.

Existing Code: _XNavigational.vbhtml:

@If Model IsNot Nothing Then
    @<text>
          <ul class="x-navigation">
           .....
           .....
          </ul>

  </text>
End If
1 Answers

Got the solution.

suppose "#32434e" is the already set background color in CSS file, if new color code is "#8a2d46" then we can write...

@If Model IsNot Nothing Then
    @<text>
<ul class="x-navigation  style="background:@IIf(Model.Usertype=1, "#8a2d46", " #32434e")">
....
....
        </ul>

  </text>
End If
Related