|
 |
asp_web_howto thread: parsing na .asp-file thru OpenTextFile
Message #1 by "jonas jerndin" <jonas.jerndin@o...> on Mon, 23 Apr 2001 12:09:31
|
|
Hi all!
My problem:
I want to parse an .asp file selected by an QueryString.
Can I get the server to run the ASP-code in the file. At this moment it
only write out the filecontent, doesn´t run asp code.
Example:
<%
path = Server.MapPath("\kungsornen\product_incs")
file = path &"\product"&qStringValue&".asp"
Set theFile = Server.CreateObject("Scripting.FileSystemObject")
Set prodInfo = theFile.OpenTextFile(file, 1, FALSE)
Response.Write(prodInfo.ReadAll)
prodInfo.Close
Set prodInfo = Nothing
Set theFile = Nothing
%>
The file:
<%
doTableFSO "4", "2",_
+"Energivärde"_
+"§1450"_
+"§kJ"_
+"§ "_
+"§ "_
+"§340"_
+"§kcal"_
+"§kcal"
%>
Message #2 by "TomMallard" <mallard@s...> on Mon, 23 Apr 2001 05:48:43 -0700
|
|
You're mixing client (response.write) and server...you want to include the
code at run-time for the server only. An easy way is to declare the code on
the page as a public function and just call it after you know what the
querystring returns...and the requires a file extension of *.inc so the code
gets put on the page that needs it.
<!--#include file="../../includes/doTableFSO.inc"-->
That file would be
<%
public function doTableFSO
doTableFSO "4", "2",_
+"Energivärde"_
+"§1450"_
+"§kJ"_
+"§ "_
+"§ "_
+"§340"_
+"§kcal"_
+"§kcal"
end function
%>
Your calling page would have something like...
if (strQueryString = "doTableFSO") then
doTableFSO
end if
tom
----- Original Message -----
From: "jonas jerndin" <jonas.jerndin@o...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, April 23, 2001 12:09 PM
Subject: [asp_web_howto] parsing na .asp-file thru OpenTextFile
> Hi all!
>
> My problem:
> I want to parse an .asp file selected by an QueryString.
>
> Can I get the server to run the ASP-code in the file. At this moment it
> only write out the filecontent, doesn´t run asp code.
>
> Example:
> <%
> path = Server.MapPath("\kungsornen\product_incs")
> file = path &"\product"&qStringValue&".asp"
>
> Set theFile = Server.CreateObject("Scripting.FileSystemObject")
> Set prodInfo = theFile.OpenTextFile(file, 1, FALSE)
>
> Response.Write(prodInfo.ReadAll)
>
> prodInfo.Close
> Set prodInfo = Nothing
> Set theFile = Nothing
> %>
>
> The file:
> <%
> doTableFSO "4", "2",_
> +"Energivärde"_
> +"§1450"_
> +"§kJ"_
> +"§ "_
> +"§ "_
> +"§340"_
> +"§kcal"_
> +"§kcal"
> %>
>
>
>
Message #3 by "jonas jerndin" <jonas.jerndin@o...> on Mon, 23 Apr 2001 18:36:46
|
|
I´m thinking more of a processForm-method.
Right now I´m using Select Case but in the end it will be about 273 cases.
Message #4 by "Steve Schwarting" <steveschwarting@n...> on Tue, 24 Apr 2001 14:17:24
|
|
If you are using asp 3.0 you should be able to do a server.execute or
server.transfer to go out and execute the code in the asp files. No need
to use includes for them or to try to use the file system object.
> Hi all!
>
> My problem:
> I want to parse an .asp file selected by an QueryString.
>
> Can I get the server to run the ASP-code in the file. At this moment it
> only write out the filecontent, doesn´t run asp code.
>
> Example:
> <%
> path = Server.MapPath("\kungsornen\product_incs")
> file = path &"\product"&qStringValue&".asp"
>
> Set theFile = Server.CreateObject("Scripting.FileSystemObject")
> Set prodInfo = theFile.OpenTextFile(file, 1, FALSE)
>
> Response.Write(prodInfo.ReadAll)
>
> prodInfo.Close
> Set prodInfo = Nothing
> Set theFile = Nothing
> %>
>
> The file:
> <%
> doTableFSO "4", "2",_
> +"Energivärde"_
> +"§1450"_
> +"§kJ"_
> +"§ "_
> +"§ "_
> +"§340"_
> +"§kcal"_
> +"§kcal"
> %>
>
|
|
 |