Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP text Editor placing </BR> in file

Status
Not open for further replies.

sthibodeau

Technical User
Aug 12, 2003
39
0
0
US
How do i avoid my ASP text editor from including those characters as it is running my format of my HTML viewing. Here is my code and towards the end i do have a routine that should replace the </BR> with CRLF. Please have a look thanks...

<%

Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader &quot;pragma&quot;,&quot;no-cache&quot;
Response.AddHeader &quot;cache-control&quot;,&quot;private&quot;
Response.CacheControl = &quot;no-cache&quot;

strPassword = &quot;testing&quot;

If Request.Form(&quot;Action&quot;) = &quot;Submit&quot; Then
If Request.Form(&quot;password&quot;) = strPassword Then
If WriteToFile(Request.Form(&quot;file&quot;), Replace(Request.Form(&quot;content&quot;), VbCrLf, &quot;</br>&quot;)) Then
JSalert(Request.Form(&quot;file&quot;) & &quot; updated successfully.&quot;)
Else
JSalert(&quot;Error writing to &quot; & Request.Form(&quot;file&quot;) & &quot;.&quot;)
End If
Else
JSalert(&quot;Invalid Password... Please Try Again.&quot;)
End If
End If

Function JSalert(strAlert)
Response.Write &quot;<script language=&quot;&quot;javascript&quot;&quot;>alert(&quot;&quot;&quot; & strAlert & &quot;&quot;&quot;)</script>&quot;
End Function

Function ReadAllTextFile(strFile)
Const ForReading = 1
Dim fso, f
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
On Error Resume Next
Set f = fso_OpenTextFile(Server.MapPath(strFile), ForReading, False)
If Err Then
ReadAllTextFile = &quot;&quot;
Exit Function
End If
ReadAllTextFile = f.ReadAll
f.Close
Set f = nothing
Set fso = nothing
End Function

Function WriteToFile(strFile, strText)
Const ForWriting = 2
Dim fso, f
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
'On Error Resume Next
Set f = fso_OpenTextFile(Server.MapPath(strFile), ForWriting, True)
If Err Then
WriteToFile = False
Exit Function
End If
f.Write strText
f.Close
Set f = nothing
Set fso = nothing
WriteToFile = True
End Function

Sub showContent(strFile, r, c)
If Request.Form(&quot;file&quot;) = strFile AND Request.Form(&quot;Action&quot;) <> &quot;Reset&quot; Then
showForm strFile, Request.Form(&quot;content&quot;), r, c
Else
showForm strFile, Replace(ReadAllTextFile(strFile), &quot;</br>&quot;, VbCrLf), r, c
End If
End Sub

Sub showForm(strFile, strContent, r, c)
%>
<form method=&quot;POST&quot;>
<input type=&quot;hidden&quot; name=&quot;file&quot; value=&quot;<%=strFile%>&quot;>
<table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr>
<td bgcolor=&quot;#000000&quot;><font color=&quot;#FFFFFF&quot; face=&quot;courier&quot; size=&quot;1&quot;>Password: <input type=&quot;password&quot; name=&quot;password&quot; size=&quot;6&quot;> <input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;Action&quot;>
<input type=&quot;submit&quot; value=&quot;Reset&quot; name=&quot;Action&quot;> (<%=strFile%>)
</font></td>
</tr>
<tr>
<td><p align=&quot;center&quot;><textarea rows=&quot;<%=r%>&quot; name=&quot;content&quot; cols=&quot;<%=c%>&quot;><%=strContent%></textarea></p></td>
</tr>
</table>
</form>
<%
End Sub
%>
 
I placed your code but it is not working. Maybe you have another trick up your sleeve or maybe you can explain that statment so i can understand how it works and maybe get it to work in my ASP page - Thanks
 
This is how the line should look

<td><p align=&quot;center&quot;><textarea rows=&quot;<%=r%>&quot; name=&quot;content&quot; cols=&quot;<%=c%>&quot;><%=replace(strContent,&quot;<BR>&quot;,chr(10),1,-1,vbTextCompare)%></textarea></p></td>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top