Bohn
Bohn

Reputation: 26919

Color style is not getting applied at run time

In my Razor I am doing this:

string style = Model.GetDateStyle(license.ExpirationDate);
<label class="control-label resultValueLabel" style=@style>@license.ExpirationDate</label>

From the implementation I have written for GetDateStyle() method if I put a break point I can see that "color: red;" is coming to style variable above. BUT it does NOT change the color of the label to red, Why?

Upvotes: 0

Views: 52

Answers (2)

Mike Debela
Mike Debela

Reputation: 1950

Razor declaration is incorrect:

 @{string style = Model.GetDateStyle(license.ExpirationDate);}
 <label class="control-label resultValueLabel" style="@style">@license.ExpirationDate</label>

Upvotes: 1

Satpal
Satpal

Reputation: 133403

Specify the variable in quotes.

<label class="control-label resultValueLabel" style="@style">@license.ExpirationDate</label>

Upvotes: 3

Related Questions