渲染VAR多个空格 [英] Render multiple spaces in var
本文介绍了渲染VAR多个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的VAR添加多个空格,但它获得的削减到一个空格或它呈现出与放大器; NBSP;原样。我一直在使用和放大器审判; NBSP;和%20任何一个有任何其他的想法?
ViewBag.Subheading =带给光;
块引用>我希望它看起来像这样
带给    光
解决方案ViewBag.Subheading =带给光.Replace(,&放大器; NBSP;);
和
@ Html.Raw(ViewBag.Subheading)
或者你可以这样做:
公共静态MvcHtmlString DisplayAndRetainSpaces(这个HTML的HtmlHelper,字符串值)
{
返回MvcHtmlString.Create(value.Replace(,与& NBSP;));
}然后调用它像:
@ Html.DisplayAndRetainSpaces(ViewBag.Subheading)
I am trying to add multiple spaces in my var but it get's cut down to one space or it renders out & nbsp; as is. I have tried using & nbsp; and %20 any one have any other ideas?
ViewBag.Subheading = "Bringing to light";
I want it to look like this
Bringing to light
解决方案ViewBag.Subheading = "Bringing to light".Replace(" ", " ");
And
@Html.Raw(ViewBag.Subheading)
Or you could do something like:
public static MvcHtmlString DisplayAndRetainSpaces(this HtmlHelper html, string value) { return MvcHtmlString.Create(value.Replace(" ", " ")); }
Then call it like:
@Html.DisplayAndRetainSpaces(ViewBag.Subheading)
这篇关于渲染VAR多个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文