View Full Version : asp help: what code do you put to do this?
timchak
June 27th, 2001, 09:08
:confused:
How do I do this:
http://www.myserver.com/default.asp?src=/url/test/page.htm
I know it would take two different pages: the default.asp (which is the template) and the page.htm (which would be the content inside the template that is in default.asp, but what would be the code for all this?
gyrbo
June 27th, 2001, 17:09
I don't know ASP but that's fairly easy in PHP.
<html>
<head><title>TITLE</title></head>
<body>
Some header info
<?php
include($src);
?>
Footer info
</body>
</html>
puDDs
June 27th, 2001, 21:11
Originally posted by timchak
:confused:
How do I do this:
http://www.myserver.com/default.asp?src=/url/test/page.htm
I know it would take two different pages: the default.asp (which is the template) and the page.htm (which would be the content inside the template that is in default.asp, but what would be the code for all this?
<html>
<head>
<title>Default.asp</title>
</head>
<body>
<% Server.Execute("page.htm") %>
</body>
</html>
As an alternative, you could just use an SSI call in your ASP
page...
<html>
<head>
<title>Default.asp</title>
</head>
<body>
<!--#include virtual="page.htm"-->
</body>
</html>
ashben
June 27th, 2001, 23:32
<%
incpage = Request.QueryString("src")
Server.Execute(incpage)
%>
timchak
June 27th, 2001, 23:48
ok...this is what I have so far, but it doesn't seem to work.
<html>
<head>
<title>Title</title>
</head>
<body>
<%
incpage = Request.QueryString("src")
Server.Execute(incpage)
%>
</body>
</html>
If i run this file itself (obviously) it doesn't work.
First of all, is this right? Is there supposed to be quotes around the "incpage" in line 9? Also, is there a way to set a default page just if they just put www.website.com? Secondly, where am I supposed to put the src webpage? If my domain is hi.com (for example) and my src is /home/index.htm, then would the location of the page be www.hi.com/home/index.htm or C:\home\index.htm?
Thanks very much for your help, everybody. I really appreciate it.
ashben
June 28th, 2001, 04:28
Can you makeout the version of ASP you are running? Server.Execute() only works with ASP 3.0
To handle a default page you can modify the script as follows:
<%
incpage = Request.QueryString("src")
if incpage="" then incpage="/home/index.htm"
Server.Execute(incpage)
%>
If you're not running ASP 3.0 then the following workaround script should solve your problem:
<%
incpage = Request.QueryString("src")
if incpage="" then incpage="/home/index.htm"
set fso = Server.CreateObject("Scripting.FileSystemObject")
set fil = fso.OpenTextFile(Server.MapPath(incpage))
outstring = fil.ReadAll
' PRE tags preserve the format of the file
Response.write "<PRE>" & outstring & "</PRE><BR>"
set fil = nothing
set fso = nothing
%>
By the way, you don't need quotes around incpage since its a variable not a string.
Important: This technique would only work for HTML (static) pages. That is, you can only pass html pages to this script. But the one for ASP 3.0 would handle all types of scripts.
Hope it helps!
gyrbo
June 28th, 2001, 05:05
Give me php, lots of easier!
timchak
June 28th, 2001, 11:40
Thanks ashben...
The second one works, so I guess the problem is that I don't have ASP 3.0.
Thanks very much everybody!
Hellbound
June 28th, 2001, 17:32
Originally posted by gyrbo
Give me php, lots of easier!
How is <?php include($src); ?> any easier then
<% Server.execute("page.htm")%> ?
I've found ASP to be just as easy. It just takes alot of flak because it's from Microsoft.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.