Response.Write containing %>

D

Dom

Hi,

I writing code that will create asp pages using the file system object. I'm
trying something like this without much luck

<%
..
..
'other code here

Response.Write "<%sName=" & Var & "%>"

%>

How can I do this?

Thanks, Dom
 
J

James Jones

now do you want VAR written out? or is that an actual variable on your
pages?



<%
Response.Write "<%sName=" & Var & "%>"
%> ^^ is that a variable you
are trying to write out? or do you want all that in quotes written out,
start with the first < and ending with the last >
 
D

Dom

This is the code I'm actually using:

<%
Dim oFileSystemObject, oFile, sFile, sPageContent

Set oFileSystemObject = CreateObject("Scripting.FileSystemObject")

sFile = Server.MapPath("/services/test_inc.asp")

Set oFile = oFileSystemObject.OpenTextFile(sFile, 1, false, 0)

sPageContent = "<%iProductID=" & iID & "%>"
sPageContent = sPageContent & oFile.ReadAll

Set oFile = oFileSystemObject.CreateTextFile("C:\Inetpub\wwwroo\test.asp",
true)

oFile.WriteLine(sPageContent)

oFile.Close()
Set oFile = Nothing
Set oFileSystemObject = Nothing
%>
 
M

Michael Kujawa

Dom said:
Hi,

I writing code that will create asp pages using the file system object. I'm
trying something like this without much luck

<%
.
.
'other code here

Response.Write "<%sName=" & Var & "%>"

%>

How can I do this?

Thanks, Dom

try this

response.write "&lt;%sName=" & Var & "%&gt;"
 
D

Dom

now do you want VAR written out? or is that an actual variable on your
pages?



<%
Response.Write "<%sName=" & Var & "%>"
%> ^^ is that a variable you
are trying to write out? or do you want all that in quotes written out,
start with the first < and ending with the last >

Var is a variable. I've posted the actual code.
 
D

Dom

This is the code I'm actually using:

<%
Dim oFileSystemObject, oFile, sFile, sPageContent

Set oFileSystemObject = CreateObject("Scripting.FileSystemObject")

sFile = Server.MapPath("/services/test_inc.asp")

Set oFile = oFileSystemObject.OpenTextFile(sFile, 1, false, 0)

sPageContent = "<%iProductID=" & iID & "%>"
sPageContent = sPageContent & oFile.ReadAll

Set oFile = oFileSystemObject.CreateTextFile("C:\Inetpub\wwwroo\test.asp",
true)

oFile.WriteLine(sPageContent)

oFile.Close()
Set oFile = Nothing
Set oFileSystemObject = Nothing
%>
 
J

James Jones

<%
var = "James Jones"
Response.Write "<%" & "sName = " & Var & "%>"
%>


that will display

<%sName=James Jones%>


<%
Response.Write "<%" & "sName = & Var & %>"
%>

that will display:

<%sName = & Var & %>






hope this was helpful
 
D

Dom

<%
var = "James Jones"
Response.Write "<%" & "sName = " & Var & "%>"
%>


that will display

<%sName=James Jones%>

<%
Response.Write "<%" & "sName = & Var & %>"
%>

that will display:

<%sName = & Var & %>

hope this was helpful

It displays it on the page, however, IIS isn't processing it a VB script,
just outputting it as HTML.
 
J

James Jones

what are you wanting it to display exactly?


type in what you are wanting to show, if you could
 
D

Dom

James Jones said:
what are you wanting it to display exactly?


type in what you are wanting to show, if you could
I want the script to assign data to the variable correctly.

I posted the actual code earlier if you look through previous posts. I'm
trying to create an asp page using the file system object with embedded vb
scripts. Driving me bonkers now!
 
B

Bob Barrows [MVP]

Dom said:
I want the script to assign data to the variable correctly.

I posted the actual code earlier if you look through previous posts.
I'm trying to create an asp page using the file system object with
embedded vb scripts. Driving me bonkers now!

Posting code is not the same as posting the results you wish to see from the
code. Look at it this way: you say the code is not working correctly. So how
are we supposed to tell by looking at your code what your desired result
should be?

You're starting to drive us bonkers now.

Let me reword it. if the code was to work correctly, and you ran the page,
and viewed source of the resulting page, what would you see as a result of
the code?

One little quirk you should be aware of:

You need to separate the < from the % when response.writing those
characters:

Response.Write "<" & "%" ...
 
M

Michael Kujawa

sPageContent = "<%iProductID=" & iID & "%>"

If you do not want the "value" of iID written to the asp file
but indeed want the variable to be processed in the new
asp page you are creating then do as below.

response.write "<% ProductID = iID %>"

this will generate
<% ProductID = iID %>

If you want productID to be pre-assigned in the new page
then
response.write "<% ProductID = " & """" & iID & """" & "%>"

this will generate the following

<% ProductID = "value of iID" %>
 
D

Dom

Posting code is not the same as posting the results you wish to see from
the code. Look at it this way: you say the code is not working correctly.
So how are we supposed to tell by looking at your code what your desired
result should be?

The code in my first post said it all. It's not exactly a difficult problem,
just a quirk as you pointed out, and as I orginally thought. Did you read
the first post or just decide to chip in towards the end?
Let me reword it. if the code was to work correctly, and you ran the page,
and viewed source of the resulting page, what would you see as a result of
the code?

Why complicate the problem - it's a *simple* question.
One little quirk you should be aware of:

You need to separate the < from the % when response.writing those
characters:

Response.Write "<" & "%" ...

The answer! Didn't hurt, did it?
 
A

Aaron Bertrand [SQL Server MVP]

Response.Write "<" & "%" ...
The answer! Didn't hurt, did it?

Yes, it did, because we had to pull teeth asking multiple times what RESULT
you wanted. Why is that part so hard?
 
P

Patrice

Response.Write just displays whatever you tell it to display (wether or not
it looks like ASP code, it's just "data"). You could use Execute or Eval to
actually run this generated code.

You may want also to tell us what is the problem you are trying to solve.
Creating a program that creates code that should then run is likely rarely
needed and it could be perhaps possible to achieve what you are trying to do
in a simpler way...
 
M

Mike Brind

Dom said:
The code in my first post said it all. It's not exactly a difficult problem,
just a quirk as you pointed out, and as I orginally thought. Did you read
the first post or just decide to chip in towards the end?

I'll chip in towards the end...

Next time you want some help from volunteers in news groups (no one
here is obliged to provide you any assistance), I suggest you read this
thoroughly before bashing out your ill-framed questions:

http://www.catb.org/~esr/faqs/smart-questions.html#forum
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top