Print Page | Close Window

Plain text

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3620
Printed Date: 29 March 2026 at 6:50pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Plain text
Posted By: Mc Brain
Subject: Plain text
Date Posted: 17 June 2003 at 7:36pm

How do you get to show a plain text in an ASP? I want to show some html code (in the page), so that the user can copy and paste it (in their pages). But I want the "<" to be pasted as "<" and not like "&lt;"... and all that stuff.

How can I do this?




Replies:
Posted By: Gullanian
Date Posted: 18 June 2003 at 12:54am

If you mean show ASP code on a page, then the quickest way is to use the <xmp> tag, however im unsure of its compatability, other than that using &lt; and &gt; for the < and > at the start and end of code is fine.

http://www.w3schools.com - www.w3schools.com has a list of these types of shortcuts



Posted By: Bullschmidt
Date Posted: 18 June 2003 at 2:41am

Or you might try something using Server.HTMLEncode such as this:

<%
varFld = "Hi <b>there</b>"
varFld = Server.HTMLEncode(varFld)
Response.Write varFld
%>

And the above would show all the code in the initial varFld = line and the word "there" would NOT be bold but instead the user would see the bold tags around it.



-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)


Posted By: Mc Brain
Date Posted: 18 June 2003 at 4:00am

I cannot understand, Bullschmidt why when I tried in a single ASP with nothing but the lines you wrote it worked.... and when I tried to implemented within the ASP I had, it doesn't:

Function Encode(sCode)

   Encode = Server.HTMLEncode(sCode)

End Function

<% Response.Write Encode("<!-- " & StartCaption & "-->") %>

I get the "&lt;" pasted instead of the "<". What's going wrong here?

 



Posted By: Bullschmidt
Date Posted: 18 June 2003 at 6:45am
Yes it does seem like it would do the "&lt;" thing but at least it's down automatically even though the user originally pasted in a < .  I just thought it was another approch worth considering.

-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net