Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to print <% Response.ContentType .... in a file ????

Posted on 2002-04-15
5
Medium Priority
?
326 Views
Last Modified: 2012-08-13
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile("c:\test.txt", true)
objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel"" %>")
Set objFN = Nothing
Set objFS = Nothing
%>


When I ran it, I got this error :

Unterminated string constant

/e.asp, line 4

objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel""
-----------------------------------------------------------------------^


How to fix it ? I must print <% Response.ContentType = "application/vnd.ms-excel" %> into a file.
0
Comment
Question by:decae2001
  • 3
5 Comments
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6943981
try

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 6943985
fix:

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & 
chr(37) & chr(62))
0
 
LVL 20

Accepted Solution

by:
Michel Sakr earned 800 total points
ID: 6943993
fixed final:

<%@ Language=VBScript %>
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile(server.MapPath("test.txt"), true)
objFN.WriteLine(chr(60) & chr(37) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
Set objFN = Nothing
Set objFS = Nothing
%>
0
 
LVL 1

Expert Comment

by:falconew
ID: 6944308
Try this:
objFN.WriteLine("<% Response.ContentType = """application/vnd.ms-excel""" %>")

REgards,
Falconew
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6944498
you don't really need to use the chr function... just make sure you separate the < and the % ....

objFN.WriteLine("<" & "% Response.ContentType .....


ASPGuru
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question