Print Page | Close Window

Naming an output file

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=3442
Printed Date: 29 March 2026 at 5:00pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Naming an output file
Posted By: l15aRd
Subject: Naming an output file
Date Posted: 11 June 2003 at 3:20am

I have written a page that can output to a word doc, but ran into a problem, I wanted to name the output file the same a the posting, here's the code i've done:

<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"

%>
<!--#include file="db.asp"-->

<%
response.buffer = true

'get key
key = request.querystring("key")
if key="" or isnull(key) then
 key=request.form("key")
end if
if key="" or isnull(key) then response.redirect "it_postslist.asp"

'get action
a=request.form("a")
if a="" or isnull(a) then
 a="I" 'display with input box
end if

' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str

Select Case a
 Case "I": ' Get a record to display

  tkey = key
  strsql = "SELECT * FROM [Posts] WHERE [PostsNo]=" & tkey

  set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open strsql, conn
  If rs.EOF Then
   Response.Clear
   Response.Redirect "it_postslist.asp"
  Else
   rs.MoveFirst
  End If

  ' Get the field contents
  x_PostsNo = rs("PostsNo")
  x_DatePosted = rs("DatePosted")
  x_Title = rs("Title")
  x_Post = rs("Post")

  rs.Close
  Set rs = Nothing

End Select
%>

 

<p>
<form>
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=itpost.doc"
%>

<table border="0" cellspacing="0" cellpadding="4">

<tr>
<td ><font face="Arial" size="1"><B>Title</B>:&nbsp;<% response.write x_Title %></font>&nbsp;</td>
</tr>
<tr>
<td ><font face="Arial" size="1"><B>Post:&nbsp;</B><%= replace(x_Post & "",chr(10),"<br>") %></font>&nbsp;</td>
</tr>
</table>
</form>
<p>

can anyone help?, I've highlighted the code that creates the file in blue

Thanx in advance



-------------

http://www.drunkentechie.net - DrunkenTechie.net

You can logoff, but you can never leave



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