I'm using an asp to fill a textarea html element "dynamically", that is, I'm filling it as the server completes calculations so the user can follow the progress (I use response.flush to send Javascript to the client periodically to update the 'value' property of the textarea).
Problem is, I can't seem to add line feeds to show information on separate lines. In Html, if the info is on separate lines, it shows on separate lines in the TextArea element, i.e.:
<Textarea>
line one
line two
</Textarea>
But when I try to 'append' a line feed, carriage return or both to the 'value' property of the TextArea element, it shows up as a 'box' character instead of being recognized as a line feed.
Any suggestions (other than building the entire contents of the TextArea element on the server before sending - that would defeat the purpose of the technique)
For now, I'm padding with spaces so things 'wrap' properly, but there's got to be a better way. If I ever wanted to let the client print the contents of the TextArea, I'd have to do all the line breaks in code.
Here's some test code (just to illustrate the technique):
<% @enablesessionstate=false %>
<% response.buffer=true %>
<%
response.write "<html>"
response.write "<head>"
response.write vbcrlf + "<Script Language='JavaScript'>" + vbcrlf
response.write "<!--" + vbcrlf
response.write "function ProcessContent(Content){" + vbcrlf
'response.write "alert(Content);" + vbcrlf
'response.write "select1.options.length=select1.options.length + 1;"
'response.write "select1.options[select1.options.length - 1].text=Content;" + vbcrlf
response.write "select1.value=select1.value+Content+vbcrlf;" + vbcrlf
response.write "}" + vbcrlf
response.write "-->" + vbcrlf
response.write "</Script>" + vbcrlf
response.write "</head>"
line="<body onload=" + chr(34) + "alert('Body Loaded')" + chr(34) + ">"
response.write line
'response.write "<Select size=10 id='select1' multiple='true'><Option>This is the first option. Does it display?</Option></Select>"
response.write "<TextArea readonly rows=20 cols=60 id='select1'>This is the first option. Does it display?" + chr(10) + "</TextArea>"
line="<DIV id='Div1'>This is the first Div1</DIV>"
response.write line
response.flush
response.write "<Table id='Table1' border=1 cellspacing=0 cellpadding=0 bgColor='White'>"
for i=1 to 100
response.write "<td border=0 bordercolor=white> </td>"
next
response.write "</Table>"
response.flush
'line="<img style='display:none' onerror='ProcessContent(this.alt)' alt='This is the content to be sent' src='blah'>"
'response.write line
'response.flush
'line="<img style='display:none' onerror='ProcessContent(this.alt)' alt='This is more content to be sent' src='blah'>"
'response.write line
'response.flush
for i=1 to 1000
Content="This is content line " & i
for l=1 to (60-len(Content))
Content=Content+" "
next
Progress=int(i/10)
if Progress>99 then
Progress=99
end if
' Progress=20
response.write vbcrlf + "<Script Language='Javascript'>" + vbcrlf
response.write "<!--" + vbcrlf
response.write "Content='" & Content & "';" + vbcrlf
' response.write "select1.options.length=select1.options.length + 1;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].text=Content;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].selected=true;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].selected=false;" + vbcrlf
response.write "select1.value=select1.value + Content;" + vbcrlf
response.write "select1.scrollTop=select1.scrollHeight;" + vbcrlf
response.write "for (var k=0; k<" & (Progress+1) & "; k++)" + vbcrlf
response.write "{" + vbcrlf
response.write "Table1.rows[0].children[k].bgColor='Blue';" + vbcrlf
response.write "Table1.rows[0].children[k].borderColor='Blue';" + vbcrlf
response.write "}" + vbcrlf
response.write "-->" + vbcrlf
response.write "</Script>"
response.flush
if response.isclientconnected=false then
response.end
end if
' if i=100 then
' while response.isclientconnected<>false
' wend
' response.end
' end if
' for j=0 to 1000
' next
next
response.write "</body>"
response.write "</html>"
response.flush
%>
Problem is, I can't seem to add line feeds to show information on separate lines. In Html, if the info is on separate lines, it shows on separate lines in the TextArea element, i.e.:
<Textarea>
line one
line two
</Textarea>
But when I try to 'append' a line feed, carriage return or both to the 'value' property of the TextArea element, it shows up as a 'box' character instead of being recognized as a line feed.
Any suggestions (other than building the entire contents of the TextArea element on the server before sending - that would defeat the purpose of the technique)
For now, I'm padding with spaces so things 'wrap' properly, but there's got to be a better way. If I ever wanted to let the client print the contents of the TextArea, I'd have to do all the line breaks in code.
Here's some test code (just to illustrate the technique):
<% @enablesessionstate=false %>
<% response.buffer=true %>
<%
response.write "<html>"
response.write "<head>"
response.write vbcrlf + "<Script Language='JavaScript'>" + vbcrlf
response.write "<!--" + vbcrlf
response.write "function ProcessContent(Content){" + vbcrlf
'response.write "alert(Content);" + vbcrlf
'response.write "select1.options.length=select1.options.length + 1;"
'response.write "select1.options[select1.options.length - 1].text=Content;" + vbcrlf
response.write "select1.value=select1.value+Content+vbcrlf;" + vbcrlf
response.write "}" + vbcrlf
response.write "-->" + vbcrlf
response.write "</Script>" + vbcrlf
response.write "</head>"
line="<body onload=" + chr(34) + "alert('Body Loaded')" + chr(34) + ">"
response.write line
'response.write "<Select size=10 id='select1' multiple='true'><Option>This is the first option. Does it display?</Option></Select>"
response.write "<TextArea readonly rows=20 cols=60 id='select1'>This is the first option. Does it display?" + chr(10) + "</TextArea>"
line="<DIV id='Div1'>This is the first Div1</DIV>"
response.write line
response.flush
response.write "<Table id='Table1' border=1 cellspacing=0 cellpadding=0 bgColor='White'>"
for i=1 to 100
response.write "<td border=0 bordercolor=white> </td>"
next
response.write "</Table>"
response.flush
'line="<img style='display:none' onerror='ProcessContent(this.alt)' alt='This is the content to be sent' src='blah'>"
'response.write line
'response.flush
'line="<img style='display:none' onerror='ProcessContent(this.alt)' alt='This is more content to be sent' src='blah'>"
'response.write line
'response.flush
for i=1 to 1000
Content="This is content line " & i
for l=1 to (60-len(Content))
Content=Content+" "
next
Progress=int(i/10)
if Progress>99 then
Progress=99
end if
' Progress=20
response.write vbcrlf + "<Script Language='Javascript'>" + vbcrlf
response.write "<!--" + vbcrlf
response.write "Content='" & Content & "';" + vbcrlf
' response.write "select1.options.length=select1.options.length + 1;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].text=Content;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].selected=true;" + vbcrlf
' response.write "select1.options[select1.options.length - 1].selected=false;" + vbcrlf
response.write "select1.value=select1.value + Content;" + vbcrlf
response.write "select1.scrollTop=select1.scrollHeight;" + vbcrlf
response.write "for (var k=0; k<" & (Progress+1) & "; k++)" + vbcrlf
response.write "{" + vbcrlf
response.write "Table1.rows[0].children[k].bgColor='Blue';" + vbcrlf
response.write "Table1.rows[0].children[k].borderColor='Blue';" + vbcrlf
response.write "}" + vbcrlf
response.write "-->" + vbcrlf
response.write "</Script>"
response.flush
if response.isclientconnected=false then
response.end
end if
' if i=100 then
' while response.isclientconnected<>false
' wend
' response.end
' end if
' for j=0 to 1000
' next
next
response.write "</body>"
response.write "</html>"
response.flush
%>