Solved

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

Posted on 2002-04-15
5
256 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:Silvers5
Comment Utility
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:Silvers5
Comment Utility
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:
Silvers5 earned 200 total points
Comment Utility
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
Comment Utility
Try this:
objFN.WriteLine("<% Response.ContentType = """application/vnd.ms-excel""" %>")

REgards,
Falconew
0
 
LVL 11

Expert Comment

by:ASPGuru
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now