Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How I can convert linebreaks of a textbox multiple with razor?
I'm not sure how you'd do this in razor but I know that if you click on the 'insert umbraco page field' in the template editor, you can click a checkbox to convert line breaks to <br /> tags automatically. Is there any way you can use this to save you having to do the conversion in razor?
I must get the value of a textbox multiple in razor and not in a template.
With xslt this is the solution: <xsl:value-of select="umbraco.library:ReplaceLineBreaks(property)" disable-output-escaping="yes"/>
In a template it works with <umbraco:Item field="property" convertLineBreaks="true" runat="server" />, but I need this function in Razor :-(
Just use umbraco.library:ReplaceLineBreaks() the Umbraco Library will work in Razor, not sure if you have to ad a reference as I don't use Razor at the moment.
Does this help? http://stackoverflow.com/questions/4220381/replace-line-break-characters-with-br-in-asp-net-mvc-razor-view
I have found the solution. It's very easy:
I know this is an older post, but it helps me to today, so thanks for share your solution Sören
It may be even easier.. I needed to convert a string from a multiline text into text with <br /> tags for the line return.. - the above method did't work with umbraco.fields..
Far too easy :)
It showed up in the available attributes/ named arguments in visual studio intellisence. (I love that stuff!!!)
Nice spot, Rob - I knew there must be a simpler way!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted