Textarea Inside of a textarea

W

wperry1

I am writing a small database utility to catalog all of my favorite
ASM/JS/VBS... functions and scripts on an asp page. Everything is going
smoothly except for one thing that I can't quite seem to think my way
around.

I am using a <textarea> to display the code but some of my scripts have
<textarea> tags in them and when the </textarea> tag is entered, it
closes my <textarea> and the rest of the code ends up outside of the
textarea.

Example: (the code after the middle </textarea> show up outside of the
textarea box)

<textarea>
code...code...code...
code...<textarea></textarea>code...
code...code...code...
</textarea>

Anyone Got any Ideas? The page/code that is giving me a headache is
here...
http://www.wperry.net/projects/codelib/detail.asp?id=19
 
M

McKirahan

I am writing a small database utility to catalog all of my favorite
ASM/JS/VBS... functions and scripts on an asp page. Everything is going
smoothly except for one thing that I can't quite seem to think my way
around.

I am using a <textarea> to display the code but some of my scripts have
<textarea> tags in them and when the </textarea> tag is entered, it
closes my <textarea> and the rest of the code ends up outside of the
textarea.

Example: (the code after the middle </textarea> show up outside of the
textarea box)

<textarea>
code...code...code...
code...<textarea></textarea>code...
code...code...code...
</textarea>

Anyone Got any Ideas? The page/code that is giving me a headache is
here...
http://www.wperry.net/projects/codelib/detail.asp?id=19

Dim s
s = "code...code...code..." & vbCrLf
s = s & "code...<textarea></textarea>code..." & vbCrLf
s = s & "code...code...code..." & vbCrLf
s = Replace(s,"<","&lt;")
s = Replace(s,">","&gt;")


<textarea><%=s%></textarea>
 
W

Will

Anthony said:
<textarea>
<%=Server.HTMLEncode(varMyContent)%>
</textarea>

Anthony.

This is essentilaly what I am doing now. The problem is that when
varMyContent contains <textarea></textarea> the </textarea> closes the
textarea tag that is supposed to contain the code.
 
W

Will

McKirahan said:
Dim s
s = "code...code...code..." & vbCrLf
s = s & "code...<textarea></textarea>code..." & vbCrLf
s = s & "code...code...code..." & vbCrLf
s = Replace(s,"<","&lt;")
s = Replace(s,">","&gt;")


<textarea><%=s%></textarea>

I though for sure that I would end up with the escape codes displayed
in the text area if I did it tis way but I read your post and decided
to try it. It works like a charm.

Thanks a lot.
 
B

Bob Lehmann

Then you are doing something wrong.

<%
var = "<textarea> some stuff</textarea>"
%>
<form method=post action="">
<textarea name="" rows="20" cols="40"><%=server.htmlencode(var)%></textarea>
</form>

Bob Lehmann
 
A

Anthony Jones

Will,

Seriously, why are you not using Server.HTMLEncode ???

What happens if you code contains &? That also needs escaping.

Anthony.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top