Forum Moderators: open
Is the data store that the information being sent into retaining the line breaks? If you are passing things around in the querystring, the URL encoded value for the new line, a carriage-return line-feed, it is %0D%0A
Make sure that your textarea text is encoded correctly when it's on it's way out to the script and you should be good.
I mocked up an example in .Net of passing URL encoded information into a textbox if you would like to see it.
Sorry, I don't mean to either talk under or over you, but I don't know your level of experience.. just offering my 2 cents :)
-Mark
<html>
<body>
<font face="arial">
<!--Creats and Saves File-->
<form action="save.asp">
<table border="1" cellpadding="0" cellspacing="0" width="550" style="border-collapse: collapse" bordercolor="#000000">
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<% if request("filename") > 0 then %>
<td colspan="2" bgcolor="cfcfcf"> 
THIS IS THE FILE THAT YOU ARE CURRENTLY WORKING ON:
<font color="red">
<% response.write(request("directory") & request("filename") & ".vtx") %> 
</td>
</tr>
<%else%>
<tr>
<td colspan="2" bgcolor="cfcfcf"> 
You do not have a file open.
</td>
</tr>
<%end if%>
</table>
</td></tr>
<tr><td>
<table cellpadding="0" cellspacing="0" width="100%">
<!--<tr>
<td><font face="arial">File Name:</td>
<td><input type="text" name="filename" value="<%=request("filename") %>" size="20">.vtx</td>
</tr>
<tr>
<td><font face="arial">Page Number:</td>
<td><input type="text" name="pagenum" size="20"></td>
</tr>-->
<tr>
<td><font face="arial">Coding:</td>
<td><textarea rows=20 cols=50 name="coding"><%=request("coding") %></textarea></td>
</tr>
<tr>
<td><font face="arial">Directory/File Name:</td>
<td><input type="text" name="directory" value="e:\wwwroot\testfolder\" size="20"> \
<input type="text" name="filename" value="<%=request("filename") %>" size="20"> .vtx</td>
</tr>
<tr>
<td colspan="2" align="middle"><input type="submit" name="Submit" value="Save"></form></td>
</tr>
<% if request("err") = filename then %>
<tr>
<td bgcolor="red" colspan="2"><b><center>YOU MUST ENTER A VALID FILE NAME!</b></td>
</tr>
<% else %>
<tr>
<td height="1"></td>
</tr>
<%end if%>
</table>
</td></tr>
<!--<tr><td>
<!--Opens File
<form action="opendoc.asp">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>Directory and filename:</td>
<td><input type="text" name="directory" value="e:\wwwroot\testfolder\" size="20"><input type="text" name="filename" size="20">.vtx</td>
</tr>
<tr>
<td colspan="2" align="middle"><input type="submit" name="Submit" value="Open"></form></td>
</tr>
</table>
</td></tr>-->
<tr><td>
<table>
<tr>
<td>
Full URL String:<br><font size="1">
[domain.com...] color="blue">?filename=<font color="red"><%=response.write(request("filename"))%><font color="blue">&coding=<font color="red"><%=response.write(request("coding"))%><font color="blue">&directory=<font color="red"><%=response.write(request("directory"))%><font color="000000">
<!--response.write("http://www.domain.com/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))-->
</td>
</tr>
</table>
</td></tr></table>
</body>
</html>
---------------------
Here's the asp page that saves the vtx document (From this page it should redirect to the previous page, displaying all entered data in the fields exactly how they were entered.) (this would be saved as "save.asp"):
-----------------
<% If len(request("filename"))<1 then
response.redirect ("/testfolder/?err=filename" & "&filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))
End if
If len(request("coding"))<1 then
'response.write "/testfolder/?err=coding"
response.redirect ("/testfolder/?err=coding" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))
End if
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(request("directory") & request("filename") & ".vtx", ForWriting, True)
f.Write request("coding")
'response.write("/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))
response.redirect("/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))
%>
------------------------
So far, I return all data to the proper fields, except the textarea. The text area will display all entered text, untill it gets to a carriage return, then from there on, nothing is displayed.
So it looks like in any place you are referencing the values from the 'coding' textarea, you will want to URLEncode() the value.
so something along the lines of
TextAreaValue = URLEncode(Request.Form["coding"])
the output of URLEncode should produce:
Html%0D%0AThat%0D%0AMakes%0D%0ALines
so for example, one line of that file is:
response.redirect("/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding")& "&directory=" & request("directory"))
response.redirect("/testfolder/?" & "filename=" & request("filename") & "&coding=" & URLEncode(request("coding")) & "&directory=" & request("directory")) -- this should do what you want.
-Mark
this is the code for the index page with the text area
<textarea rows=20 cols=50 name="coding" style="border: 1px solid #000000"><%TextAreaValue = URLEncode(Request.Form("coding"))%></textarea>
here's one of the lines on the save.asp page
response.redirect("/docutech/?" & "filename=" & request("filename") & "&coding=" & URLEncode(rrequest("coding")) & "&directory=" & request("directory") & "&type=" & request("type"))
It's returning to the previous page with the correct url string like it should be doing, but i'm getting a VB Run Time error. The weird thing is, it loads the text area and it places the error in the text area exactly like this (code and all):
<font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a000d'</font>
<p>
<font face="Arial" size=2>Type mismatch: 'URLEncode'</font>
<p>
<font face="Arial" size=2>/docutech/index.asp</font><font face="Arial" size=2>, line 43</font>
What am i doing wrong?
Sorry, should have been more clear, just leave the original page with the textarea alone, so:
<textarea rows=20 cols=50 name="coding" style="border: 1px solid #000000"><%TextAreaValue = URLEncode(Request.Form("coding"))%></textarea> <textarea rows=20 cols=50 name="coding" style="border: 1px solid #000000"><%Request("coding")%></textarea> and I'm not sure if that's just a typo in your save.asp , but you have a double 'r' for the 'request' inside the URLEncode .
Perhaps after removing the extra 'r' that will fix it?
Mark
this is the complete codeing for the index.asp page:
----------------------------------------
<html>
<body bgcolor="ababab">
<font face="arial">
<!--Creats and Saves File-->
<form action="save.asp">
<table bgcolor="ffffff" border="1" cellpadding="0" cellspacing="0" width="550" style="border-collapse: collapse" bordercolor="#000000">
<tr>
<td bgcolor="cfcfcf">
<table cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr>
<% if len(request("filename")) < 1 then %>
<td colspan="2" bgcolor="cfcfcf"> 
You do not have a file open.
</td>
</tr>
<%else%>
<tr>
<td colspan="2" bgcolor="cfcfcf"> 
You currently have the following file open:
<font color="red">
 <% response.write(request("directory") & request("filename") & ".vtx") %> 
</td>
</tr>
<%end if%>
</table>
</td></tr>
<tr><td>
<table cellpadding="0" width="100%" style="border-collapse: collapse" border="0">
<!--<tr>
<td><font face="arial">File Name:</td>
<td><input type="text" name="filename" value="<%=request("filename") %>" size="20">.vtx</td>
</tr>
<tr>
<td><font face="arial">Page Number:</td>
<td><input type="text" name="pagenum" size="20"></td>
</tr>-->
<tr>
<td><font face="arial">Coding:</td>
<td><br><textarea rows=20 cols=50 name="coding" style="border: 1px solid #000000"><%=Request("coding")%></textarea> </td>
</tr>
<tr>
<td><font face="arial">Directory/File Name:</td>
<td>
<input type="text" name="directory" value="e:\wwwroot\testfolder\" size="20" style="border: 1px solid #000000"> 
<input type="text" name="filename" value="<%=request("filename") %>" size="20" style="border: 1px solid #000000"> .vtx</td>
</tr>
<tr>
<td colspan="2" align="middle"><input type="submit" name="Submit" value="Save"></form></td>
</tr>
</table>
</td></tr>
<!--ERROR RESPONSES-->
<% if request("err") = "filename" then %>
<tr>
<td bgcolor="red" colspan="2"><b><center><font color="ffffff">File name must be at least 7 characters.</b></td>
</tr>
<%end if%>
<% if request("err") = "filenamebig" then %>
<tr>
<td bgcolor="red" colspan="2"><b><center><font color="ffffff">File name must be 7 to 8 characters.</b></td>
</tr>
<%end if%>
<% if request("err") = "coding" then %>
<tr>
<td bgcolor="red" colspan="2"><b><center><font color="ffffff">Your coding field is empty.</b></td>
</tr>
<%end if%>
<% if request("err") = "directory" then %>
<tr>
<td bgcolor="red" colspan="2"><b><center><font color="ffffff">Please enter a valid directory.</b></td>
</tr>
<%end if%>
<!--<tr><td>
Open File
<form action="opendoc.asp">
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
<tr>
<td>Directory and filename:</td>
<td><input type="text" name="directory" value="e:\wwwroot\testfolder\" size="20"><input type="text" name="filename" size="20">.vtx</td>
</tr>
<tr>
<td colspan="2" align="middle"><input type="submit" name="Submit" value="Open"></form></td>
</tr>
</table>
</td></tr>-->
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="cfcfcf">
<tr>
<td>
Full URL String:<br><font size="1">
http://www.domain.com/testfolder/<b><font color="blue">?filename=<font color="red"><%=response.write(request("filename"))%><font color="blue">&coding=<font color="red"><%=response.write(request("coding"))%><font color="blue">&directory=<font color="red"><%=response.write(request("directory"))%><font color="000000">
<br>
Full URL String sent to save.asp:<br> <font size="1" color="red">
<% response.write("/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))%>
<!--response.write("/testfolder/?" & "filename=" & request("filename") & "&coding=" & request("coding") & "&directory=" & request("directory"))-->
</td>
</tr>
</table>
</td></tr></table>
</body>
</html>
---------------------------------------
and here is the coding for the save.asp page:
----------------------------------------
<% if len(request("filename")) < 7 then
response.redirect ("/testfolder/?err=filename" & "&coding=" & URLEncode(request("coding")) & "&directory=" & request("directory") & "&type=" & request("type"))
End if
If len(request("filename")) > 8 then
response.redirect ("/testfolder/?err=filenamebig" & "&coding=" & URLEncode(request("coding")) & "&filename=" & request("filename") & "&directory=" & request("directory") & "&type=" & request("type"))
End if
If len(request("coding")) < 1 then
response.redirect ("/testfolder/?err=coding" & "&filename=" & request("filename") & "&directory=" & request("directory") & "&type=" & request("type"))
End if
If len(request("directory")) < 1 then
response.redirect ("/testfolder/?err=directory" & "&filename=" & request("filename") & "&coding=" & URLEncode(request("coding")) & "&type=" & request("type"))
End if
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(request("directory") & request("filename") & ".vtx", ForWriting, True)
f.Write request("coding")
'response.write("/testfolder/?" & "filename=" & request("filename") & "&coding=" & URLEncode(request("coding")) & "&directory=" & request("directory") & "&type=" & request("type"))
response.redirect("/testfolder/?" & "filename=" & request("filename") & "&coding=" & URLEncode(request("coding")) & "&directory=" & request("directory") & "&type=" & request("type"))
%>