This sounds really basic yet I couldn’t find the answer.
I pass a Message struct to the View and I want to display it.
If the Message.Category field is “Technical” I want to display “Technical Problem” else just display it as it is.
How do I make the view understand that Technical Problem isn’t a statement but html text I want to display?
My code:
<span class="cright" id="cat">
@{
if (String.Compare(ViewBag.Message.Category, "Technical") == 0)
{
Technical Problem <----THIS
}
else @ViewBag.Message.Category
}
</span>
More info:
I’m working on a messaging system. Users create a message and as it is being sent they can view it. The category is compulsory (Question, Suggestion or Technical Problem) and to avoid redundancy in the database I truncate the last option to just ‘Technical’, however when the users view their sent message I want it to show up in full.
Thanks everyone; from all your answers I arrived at:
<span class="cright" id="cat">
@if (ViewBag.Message.Category == "Technical ")
{<text>Technical Problem</text>}
else
{<text>@ViewBag.Message.Category</text>}
</span>
which works just as I wanted.
Original Answer
Updated Answer