response.write

  • Thread starter Thread starter chris leeds
  • Start date Start date
C

chris leeds

Hi,
I'm passing a value in the url string. I've been able to extract it ok to
write the name on the page and also to write the images, even with prefixes
and stuff. now I want to include a text file but i can't figure out how.
here's what i want:
<!-- #include file="text/<%= key%>.txt"-->
I tried to do the response.write .... but I think the necessary " inside the
(" ") is screwing me up. i know in JavaScript you put a \before the " if
you need to write a " so what is it with asp?

TIA
 
Chris,

You don't need to do a response.write to display the text file, the Include
file statement will automatically display the content of the include file
where ever you have the statement inserted on your page.

Also, you do not need use response.write statement to show value retrieved
from a database or from a form, just use:

<%=Request.Form("FormFieldName")%>

or

<%=RecordSet("FieldName")%>

to display the content on a page.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
This won't work as includes can't be dynamic since they are processed before
the ASP.

Look into using Server.Execute() instead of an include.

<%
Server.Execute("text/" & key & ".txt")
%>

Bob Lehmann
 
Bob,

Good catch, however a Server.Execute can't include content into a page, only
redirects to another page.

But Chris, could use the FileSystemObject to include a text file based on a
value, such as:

<%
If NOT rs.EOF AND rs("DetailPage") > "" Then
DetailPage = rs("DetailPage")
Else
DetailPage = "nodetails.htm"
End If
%>

<%
SUB ReadDisplayFile(FileToRead)
DetailPage=Server.MapPath("../details/" & FileToRead)
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(DetailPage, 1, False)
tempSTR=thisfile.readall
response.write tempSTR
thisfile.Close
set thisfile=nothing
set fs=nothing
END SUB
%>
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
i think you're onto something there Thomas. ;-) see it's confusing to
extract the pertinent info from your reply.
I'm not using a database or anything. I've just got a page of thumbnail
pictures with their hyperlink targets modified to carry a key.
I'll include the page text at the bottom. all I really want is to include a
text file based on the key, just like the image files i'm controlling this
way:

<% key=request("key") %>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="100%" colspan="2">
<!--webbot bot="Include" U-Include="includes/head.htm"
TAG="BODY" --></td>
</tr>
<tr>
<td width="20%" valign="top">&nbsp;<!--webbot bot="Include"
U-Include="includes/side.htm" TAG="BODY" --><p>&nbsp;</td>
<td width="80%" align="left" valign="top">
<%response.write key %><br>
<table border="0" cellpadding="3" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="500"
id="AutoNumber2">
<tr>
<td align="center" rowspan="4"><img name="mainpic" src="images/<%=
key %>/main.jpg" width=400 height=400 border=0></td>
<td align="left" valign="top"><a href="javascript:doPic('images/<%=
key %>/main.jpg');"><img src="images/<%= key %>/tn_main.jpg" width=97
height=97 border=0></a></td>
</tr>
<tr>
<td align="left" valign="top"><a href="javascript:doPic('images/<%=
key %>/pendant.jpg');"><img src="images/<%= key %>/tn_pendant.jpg" width=97
height=97 border=0></a></td>
</tr>
<tr>
<td align="left" valign="top"><a href="javascript:doPic('images/<%=
key %>/string.jpg');"><img src="images/<%= key %>/tn_string.jpg" width=97
height=97 border=0></a></td>
</tr>
<tr>
<td align="left" valign="top"><a href="javascript:doPic('images/<%=
key %>/clasp.jpg');"><img src="images/<%= key %>/tn_clasp.jpg" width=97
height=97 border=0></a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top">xx<!-- include
file="text/<%= key%>.txt"--></td>
</tr>
</table>

happy to hear anyone's opinion.
 
Chris,

Call me.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
hmmm. I created a text file, used Server.Execute("some.txt"), and it
displayed the text.

I'm not all that familiar with the Execute and Transfer methods of the
Server object, so I may be mistaken about how they function.

Bob Lehmann
 
Bob,

Correct, but you can not use Server.Execute to have the actual content of a
file included in another page, only to redirect to another page.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
<tr>
<td colspan="2" align="left" valign="top">xx<%Server.Execute("text/" & key
& ".txt")%></td>
</tr>

Bob Lehmann
 
Bob,

I stand corrected!

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
Chris,

You might want to try out Server.Execute, it is a lot less coding!

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
thanks Thomas,
you rock!

here's what i was trying to do:
http://nedp.net/aycock/asp/prep_n.asp
and make only one "display" page, transferring a key along with the url so
it'd know what pictures and text to display.
and now it works. pictures, and text from a file all dictated by a single
key. way better than making 35 different display pages.
Thanks Again.
cl
ps check out "arrested development" on fox at 9:30 it's good. ;-)
 
tried it worked great. thanks a lot. I'm definitely keeping that trick.
:-)
thanks again,
cl
 

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

Back
Top