I write program with aspx and C# in VS2010. I want to alert all the SoftWareNotes in loop. (it's a varchar value in my DB). so I did that:
<% for(Software s in Db.Softwares){ %>
<script>
var GetTextArea= '<%=s.SoftwareNotes%>' ;
alert(GetTextArea);
</script>
<%}%>
and it's work fine , until that SoftwareNotes contain /r . for example in this string: "fdbdfb\r\ndfbdf\r\ndfb" (from the debugger) , it's not print nothing, and continue to the next one.
Why and how can I fix that?
*The field SoftwareNotes contain /r cause it's populate by TextAreas ..so if someone make enter it save it like a /r.
edit 2:20: I found one solution , but it's not the best.. I write this code above the code before:
<%
String tryRemoveNL="";
if(s.SoftwareNotes!=null)
tryRemoveNL= Regex.Replace(s.SoftwareNotes, @"\r\n?|\n", " ");
%>
and now when I write:
var GetTextArea= '<%=tryRemoveNL%>' ;
it works. but I want to keep the newLines.. maybe you have other solutions?
alert("fdbdfb\r\ndfbdf\r\ndfb")in Chrome and IE 10 shows the alert with line breaks, no problem.