VS2013,MVC5, Razor ,VB
我想要在“已回答”这个词前面有空格。如何强制空格进入以下 Razor 代码块?
@Code If Model.DisplayAnsweredFlag Then
@If Model.Answered Then
@Html.Raw("Answered")
End If
End If
End Code
在 html.raw() 中,空格本身或前面文本中的空格似乎没有被编码到页面中。但我也不能在代码块中使用“ ”或“@ ”,因为它的语法不正确。
如果我使用糟糕的技术进行编码,请提出建议,或者如果有其他方法可以输入空格,请提出建议。
最佳答案
安迪布克 在这里给出了答案:
https://forums.asp.net/t/1772048.aspx?How+to+use+no+break+space+HTML+character+inside+if+brackets+in+a+view+
在那个链接中,他写道:
The introduction to Razor syntax at:
http://www.asp.net/web-pages/tutorials/basics/2-introduction-to-asp-net-web-programming-using-the-razor-syntax is quite useful.
To force html output for your string, you may use<text>
to Block or@:
as a Prefix.
@if (condition)
{
<text> </text>
@:
}
关于asp.net-mvc - 如何在 razor 代码块中插入空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28283042/