Eminem Eminem - 1 year ago 104
ASP.NET (C#) Question

C# how do I include the following in HTML

I have a MVC website which uses razor syntax. I generate a table from values from a db.
In a table cell I have some text e.g.

This is some text


this is <b>some</b> text

Now I need a word to be bold. I have tried
but that is exactly how it appears on the web page. I need it to look like

This is some text

Answer Source

The only way this could be happening is if your <b>some</b> string is coming from a variable elsewhere in your code. Razor automatically escapes this for safety reasons, but you can force it to be rendered as-is with view helpers already available in Razor.

Use the Html.Raw() helper to render a string without sanitizing it.

    This is @Html.Raw(Model[i].QuestionText) text
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download