I want to write something like:
@( checkCondition ? "<span class='label'>Right!</span>" : "")
But it is showing the source code instead the HTML, there is a easy way to do this?
Thank you!
You can use @Html.Raw(mystring)
method like this:
@( checkCondition ? Html.Raw("<span class='label'>Right!</span>") : Html.Raw(""))
You can be even more concise (granted harder to read) with this:
@Html.Raw(checkCondition ? "<span class='label'>Right!</span>": string.Empty)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With