I'm trying to format some html that will be contained within a string for use in javascript. One of the fields I am including is a text area that can have line breaks in it.
To replace these with br tags I am using umbraco.library.ReplaceLineBreaks which is adding the br tags. However there are also still line breaks in the text that is causing an error in the javascript.
This is the output I am getting
html: '<strong>Leeds Office</strong><br />4 Church Walk <br/>
Leeds<br/>
LS2 7EG<br /><a href="http://maps.google.co.uk/maps?daddr=53.79575610280947,-1.5367474779097847" target="_blank">Get Directions</a>'
but this is what I need.
html: '<strong>Leeds Office</strong><br />4 Church Walk <br/>Leeds<br/>LS2 7EG<br /><a href="http://maps.google.co.uk/maps?daddr=53.79575610280947,-1.5367474779097847" target="_blank">Get Directions</a>'
Simply replacing Environment.NewLine doesn't seem to do anything so how can I remove the line breaks from the string.
Convert and remove line breaks partial view
I'm trying to format some html that will be contained within a string for use in javascript. One of the fields I am including is a text area that can have line breaks in it.
To replace these with br tags I am using umbraco.library.ReplaceLineBreaks which is adding the br tags. However there are also still line breaks in the text that is causing an error in the javascript.
This is the output I am getting
but this is what I need.
Simply replacing Environment.NewLine doesn't seem to do anything so how can I remove the line breaks from the string.
Hi suzyb,
Maybe you could try use the ReplaceLineBreaks library method.
http://our.umbraco.org/forum/developers/razor/39891-ReplaceLineBreaks-in-Razor?p=0#comment145788
Hope this helps you.
/Dennis
After running the ReplaceLineBreaks method you could use the Replace method to remove any line breaks.
Thanks Dan.
I was trying myString.Replace(Environment.Newline, "") which didn't seem to work but your way does.
is working on a reply...