Reputation: 26919
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
Reputation: 1950
Razor declaration is incorrect:
@{string style = Model.GetDateStyle(license.ExpirationDate);}
<label class="control-label resultValueLabel" style="@style">@license.ExpirationDate</label>
Upvotes: 1
Reputation: 133403
Specify the variable in quotes.
<label class="control-label resultValueLabel" style="@style">@license.ExpirationDate</label>
Upvotes: 3