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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display asp/vbscript code in a <textarea>

Status
Not open for further replies.

iisman

Technical User
Mar 6, 2005
85
CA
Hello,

I am not sure if this is the appropriate form for this question...but here goes...

I want to display a snippet of vbscript code in a textarea. Does anyone know how this can be accomplished..?

I googled...but nothing found. I may not have been searching the correct terms. any help is appreciated.
 
I use this function for showing my code snippets.

Code:
function toCode(strItem)
'Change code delimiters to HTML entities
	strItem = Replace(strItem,"<","&lt;")
	strItem = Replace(strItem,">","&gt;")
	strItem = Replace(strItem,"%","&#37;")
	strItem = replace(strItem,chr(34),"&quot;")
toCode = strItem	
end function

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Easier would probably be Server.HTMLEncode(yourCode). It converts to HTML codes for you (though it might not handle the % sign, that convesion shouldn't be necessary).
 
I just realized that you might be trying to display something that's not in a string variable already. If so, you'll either have to do it manually:
Code:
<textarea>
  &lt;% blah blah blah %&gt;
</textarea>
or you'll need to put them in strings first:
Code:
<% strMyCode = "<% blah blah blah with quotes doubled %>" %>
<textarea>
  <%=Server.HTMLEncode(strMyCode)%>
</textarea>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top