Link to home
Start Free TrialLog in
Avatar of aspdev
aspdev

asked on

Putting ASP code as text on a page

I want to post ASP code on a page so that users who want it included on their page can "cut-n-paste". What should I do?
As soon as I type <% It reads it as a command...

I've tried <pre> witch I figured wouldn't work and didn't.

Is there any ASP command for saying "this is text"?
Avatar of sybe
sybe

Replace "<%" with "<pre>" and "%>" with "</pre>"

There is also the "viewsource.asp" which you can find in your example-asp's
Avatar of aspdev

ASKER

Well, I needed to have the "<%" ... otherwise it wouldn't be pure cut-n-paste :)

But I figured it out. All I had to do was to exchange all the "<" with "&lt;" and now it's working fine so I don't really need any solution. But thanx for trying to answer anyway.

/Marten
do it like this:

<OBJECT DATA="yourasp.txt"></OBJECT>

This will put it in a box for cut and paste.
do it like this:

<OBJECT DATA="yourasp.txt"></OBJECT>

This will put it in a box for cut and paste.
Just don't save it as an .asp page save it as an .htm.
Just don't save it as an .asp page save it as an .htm.
Avatar of aspdev

ASKER

As I said guys, I've already solved it on my own.
Sybe:The <pre> tag wont help since I want the <% to be shown...
TAMC: I still wanted to be able to format some og the text. So you idea don't work either.
MasseyM: I don't want to have to use an external file and I wouldn't be able to format some of the text.

ALL: The solution (as posted several times already) is to excange the "<" with "&lt;" that way it won't be interpreted as code. And when I want to format the text I can use the "<" to enter code. No need for an external file to be used either. Everything neatly collected in a single document.
Avatar of aspdev

ASKER

Hmm.. I figured I'd give the points to someone... Who can tell me how to write the sign " to a file via ASP? If I typ WriteLine(""") I get an obvious error-message. I want the " to BE a " in the file I write to, not just some HTML or URL code for it... how is this done?

btw: If you want to write <% or %> to a file without the ASp thinking you are trying to start/end a comman, do this WriteLine("<"&"%").
ASKER CERTIFIED SOLUTION
Avatar of shez
shez

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aspdev

ASKER

It worked fine. I guess I feel abit guilty giving you the point but on the otherhand... they didn't help me nor did they solve my problem nor did they answer this last thing in reasonable time. So here ya go!