How do I display my string that is: <b>test</b>
as: test in my html page?
I'm getting the string from my database, which was created with a wysiwyg editor.
I've tried using razor syntax:
@Html.Encode(Model.teststring);
But this doesn't work.
I've also tried using javascript, which didn't work either:
<div id="@Model.ID">
<script type="text/javascript">
$('#@Model.ID').html(Model.teststring);
</script>
</div>
Both show the text as follows: <b>test</b>
Is there a way to fix my problem?
You need to place it within the Html.Raw()
like below
@Html.Raw(Model.teststring)
This method wraps HTML markup using the IHtmlString class, which renders unencoded HTML. You can find out more about it here