Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to set css class to div dynamically in mvc view?

$
0
0

hello,

I am not getting how to do this, let me explain, I have data base having column name SignalCSS having some row (css class name) like PT1, PT2 . . . , 

now, in my model class I have property say public string SignalCSS{get;set} in this property  I am getting class name, and I have .css file in that I define my class ex.

.PT1{ background : red}

.PT2{background : green}

now, in my view i have foeach loop, where i am creating div

foreach

{

<div class=" ? "></>

}

if my property value is PT1 then I want div with red background

if it is PT2 then it shoud be green.

So how can I achieve this, I am doing my first project in mvc, please help me to get out

thanks

tink


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>