Search code examples
asp.net-mvcasp.net-mvc-3razor

Outputting nbsp; in Razor via variables?


I am having a blank here.

I need to output "nbsp;" via a variable:

string strSpacer = "  ";

So was trying:

@:strSpacer

Does not work, although I do get the following in the page source:

 

What do I need to do to resolve this please?


Solution

  • I think you're looking for @Html.Raw(strSpacer) See some more info about this function here: http://msdn.microsoft.com/en-us/library/gg480740%28v=vs.118%29.aspx