putting dynamics into header tag?

Results 1 to 2 of 2

Thread: putting dynamics into header tag?

  1. #1
    Join Date
    Dec 1969

    Default putting dynamics into header tag?

    Hi thier<BR><BR>I am in the process of re-coding a .asp page that i have that i currently have a custom header set up in iis5 so that it is issued from the server as a csv.<BR><BR>I have the code so that i can create this custom header on the page and so do not need to use IIS5 to get it issue as the required CSV. <BR><BR>What i am trying to do is as this page currently is getting files from a database is that i want to be able to alter the name and the mime type for the file by adding dynamic elements into the custome header tag for the page. This way the link I click currently use to generate the CSV file I can chage to a form and the i can name the file and choose between actually having the file as a .csv, .xls. htm anything I like.<BR><BR>currently i have everything i place but when i put the&#060;%= recordset.item."(filename").vale%&#062; into the code it doesn&#039;t work I have tried removing the &#060;%= & %&#062; from either end as it is in a &#060;% & %&#062; for the custom header any way then i have swapped the " for &#039; as it is a value within a set of " " but it is still not getting the file name i want.<BR><BR>here is the code i have currently that If i can get it read the dynamics for the header tag should do exactly what i want.<BR><BR>&#060;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&#062;<BR>&#060;!--#include file="../../Connections/database.asp" --&#062;<BR>&#060;%<BR>Dim Recordset1__MMColParam<BR>Recordset1__MMColParam = "1"<BR>If (Request.QueryString("FileID") &#060;&#062; "") Then <BR> Recordset1__MMColParam = Request.QueryString("linkID")<BR>End If<BR>%&#062;<BR>&#060;%<BR>Dim Recordset1<BR>Dim Recordset1_numRows<BR><BR>Set Recordset1 = Server.CreateObject("ADODB.Recordset")<BR>Recordse t1.ActiveConnection = MM_clickserve_STRING<BR>Recordset1.Source = "SELECT * FROM link WHERE FileID = " + Replace(Recordset1__MMColParam, "&#039;", "&#039;&#039;") + ""<BR>Recordset1.CursorType = 0<BR>Recordset1.CursorLocation = 2<BR>Recordset1.LockType = 1<BR>Recordset1.Open()<BR><BR>Recordset1_numRows = 0<BR>%&#062;<BR>&#060;%<BR>Response.AddHeader "Content-disposition","attachment; filename=(Recordset1.Fields.Item(&#039;filename&#0 39;).Value).(Recordset1.Fields.Item(&#039;filetype &#039;).Value)"<BR><BR>%&#062; <BR>&#060;%<BR>Dim F, Head<BR>For Each F In Recordset1.Fields<BR> Head = Head & ", " & F.Name<BR>Next<BR>Head = Mid(Head,3) & vbCrLf<BR>Response.ContentType = "text/plain"<BR>Response.Write Head<BR>Response.Write Recordset1.GetString(,,", ",vbCrLf,"")<BR>%&#062;<BR>&#060;%<BR>Recordset1.C lose()<BR>Set Recordset1 = Nothing<BR>%&#062;<BR><BR>any suggestions welcome as I now it is sonething silly as i am tired which is why it is doing my head in.<BR><BR><BR>Cheers<BR><BR>Summit

  2. #2
    Join Date
    Dec 1969

    Default First of all look at what you are

    here. With the following you are simply building a literal string with the NAMES of the &#039;Recordset1.Fields...etc.&#039; not the VALUES of them:<BR><BR>Response.AddHeader "Content-disposition","attachment; filename=(Recordset1.Fields.Item(&#039;filename&#0 39;).Value).(Recordset1.Fields.Item(&#039;filetype &#039;).Value)" <BR><BR>So if your field names in your should look something like this:<BR><BR>Response.AddHeader "Content-disposition","attachment; filename=" & Recordset1.("filename") & "." & Recordset1("filetype") & ";"<BR><BR>Did you notice I added the &#039;;&#039; to the end? In some cases it may make a difference. Also it might be a good idea to set your contenttype before you do this line.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts