I want to add a simple inline style to my div tag if a certain criteria is met.
I am able to apply the “disabled” class successfully, but I can’t get my cursor style to show up.
<div class="item @(item.AvailableTimeSlots == "0" ? "disabled" : "")" @(item.AvailableTimeSlots == "0" ? "style='cursor: default;'" : "")>
any pointers?
Working Snippet
Adding
Html.Raw()fixed the problem for me. Without it, you end up with something like:I tried a few different browsers, and each gave different results when inspecting the DOM. IE8 mangles it; Chrome incorrectly reworks it; IE9 appears to correctly make it well-formed.
Few notes:
item.AvailableTimeSlotsshould be an integer, not a string.