VS2013, MVC5, Razor, VB
I want spaces in front of the word 'Answered'. How do I force spaces into the following Razor code block?
@Code If Model.DisplayAnsweredFlag Then
@If Model.Answered Then
@Html.Raw("Answered")
End If
End If
End Code
In html.raw(), spaces by themselves or spaces in of front text don't seem to get coded into the page. But I also can't use ' ' or '@ ' in a Code Block because it's incorrect syntax.
If I'm coding with a poor technique, please advise, or if there is a different way to get the spaces in, please advise.
AndyBuk gave the answer here:
https://forums.asp.net/t/1772048.aspx?How+to+use+no+break+space+HTML+character+inside+if+brackets+in+a+view+
In that link he writes:
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>
@:
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With