Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, June 11, 2014 3:29 PM
Sorry if this seems like a stupid question and it probably is. But in VSWeb 2012 I am constructing a string that will appear in a SPAN element. I wish to pass <br> to allow line breaks to appear in the browser. Like so...
Message += lst.Item("list_id") & " " & lst.Item("list_api_identifier") & lst.Item("list_description") & "<br>"
Displaying the Message in Razor view as @Message, the <br> element is getting encoded to <br> in the page source.
How do I allow the unencoded <br> to pass through to the page source?
(yea I know it is VB...please no flames)
Thanks
All replies (3)
Thursday, June 12, 2014 10:34 AM âś…Answered
OK here is an update. After trying to pass \r\n to also create a line-break in a span (which did not work either), I finally tried using vbCrLf a Visual Basic constant for Carriage Return/Line-Feed and now my text displays nicely formatted with line breaks.
Thanks for the reply
Thursday, June 12, 2014 12:34 AM
try below
<span style="white-space: pre-line">@Message</span>
check Replace line break characters with <br /> in ASP.NET MVC Razor view
Thursday, June 12, 2014 7:03 AM
Thanks for the repy damithSL.
I just tried that and here is what the page source looks like...
<span style="white-space: pre-line">1656 TEST_USERSTest Users<br/>1331 fishing2013Fishing Enthusiasts<
I guess it didn't work.