View Full Version : Is This possible in asp
PlatinumProject
11-27-2002, 10:01 PM
well wat i was using php for was to use only one template and where the content would go
i put
<?php include ("$id"); ?>
and it would include the page when the link clicked
the links where like
main.php?id=the name of the file.htm
and it would show it on the main or index page
since my server don't support php i want to do this in asp but i'm not sure if it can be done i'v been expirmenting with the
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
%>
<!--#include file="news.htm"-->
<%
End If
%>
but it only works to inlcude on page when the link is clicked
index.asp?page=news.htm
i tried repeating the code to do the same with other pages but than the page would load.....
:confused:
i hope this is enough info for what i want
here is the page
http://24.226.62.28/ugs/index.asp
if you go down the links on the left side click on home it includes the file but i want the other links to be able to be included...
fractalvibes
11-27-2002, 10:58 PM
Don't think you can do this, since includes are processes before you asp script is parsed/executed.
What you could do:
If condition1 = true then
Response.Execute page1.asp
Else
Response.Execute page2.asp
End If
just put the code you would put in the include file(s) into a script(s) and save as an asp page(s).
BigDaddy
11-27-2002, 11:02 PM
How about:
<%
Dim Page
Page = Request.QueryString("page")
response.redirect("http://www.xxxx.com/" & page & ".asp")
%>
Morgoth
11-27-2002, 11:22 PM
Originally posted by fractalvibes
Don't think you can do this, since includes are processes before you asp script is parsed/executed.
What you could do:
If condition1 = true then
Response.Execute page1.asp
Else
Response.Execute page2.asp
End If
just put the code you would put in the include file(s) into a script(s) and save as an asp page(s).
Incorrect my friend.
You are thinking of IIS 4.0
IIS 5.0 runs this code fine.
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
%>
<!--#include file="news.htm"-->
<%
End If
%>
Now what your trying to do PlatinumProject is have a default page so that it's not blank. Try this:
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
%>
<!--#include file="news.htm"-->
<%
Else
%>
<!--#include file="DEFAULT PAGE"-->
<%
End If
%>
Make sense?
In an If statement You can also have ElseIf and Else statements which will allow you to do something else if the first choice is not true.
Example:
<%
If 1 + 1 = 3 Then
%>
The answer is 3
<%
ElseIf 1 + 1 = 1 Then
%>
The answer is 1
<%
Else
%>
Both Answers above were wrong so I am not sure what the answer is.
<%
End If
%>
So Else is the last thing to add if nothing above was true. But if 1 plus 1 did equal 3 then the screen would of printed "The answer is 3"
Let's make that code more simple(Becuase your new to ASP):
<%
If 1 + 1 = 3 Then
Response.Write "The answer is 3"
ElseIf 1 + 1 = 1 Then
Response.Write "The answer is 1"
Else
Response.Write "Both Answers above were wrong so I am not sure what the answer is."
End If
%>
And that is how to use Response.Write, if you didn't know.
fractalvibes:
http://24.226.62.28/file.asp
http://24.226.62.28/time.asp
http://24.226.62.28/file.asp?page=time.asp
whammy
11-27-2002, 11:40 PM
Another way is to include all the files (and each file would contain a SUB (subroutine)).
Then depending on your conditions, you can call the SUB you want. Theoretically this might be a very slight performance hit, but practically it's not, from what I've seen - first of all because all the subroutines are read, but not executed unless a condition is met... (read through RadarBob's recent posts, and you'll see even more reasons this is true... ;)).
Morgoth
11-28-2002, 12:06 AM
Originally posted by whammy
Another way is to include all the files (and each file would contain a SUB (subroutine)).
Then depending on your conditions, you can call the SUB you want. Theoretically this might be a very slight performance hit, but practically it's not, from what I've seen - first of all because all the subroutines are read, but not executed unless a condition is met... (read through RadarBob's recent posts, and you'll see even more reasons this is true... ;)).
Whammy, that's what I thought aout using when I was on IIS 4.0, but then I realized my pages are going ot be HUGE, so I just decided to use a new system.
I have one config file, and I have 3 placement files that get updated sometimes and it's better to have one file to change to fix the problem than all the pages (this is useful if you have a nav bar) I also have my main pages that I include all 4 files. Config, top, middle, and bottom.
After including Config I have my Html headers like title and calling my meta tags from inside a sub in the config file. Then I have my Top (main title graphics and main nav bar) and my Middle(side navbar, poll, and some member info) (before I use to put my top and middle together, but if you saw my site, you can see I can remove the middle and I could make a full width page if I need to. (like my forum or something). After them I have my page info, as if it were news or rules or the join page. Then I have the bottom.
I think my system works just fine, and I have gotten every error trying to do it that way along time ago when I knew very little code.
I recently Rewrote all the code and all the html so it's more efficent and such. but I went completely off topic.
Maybe If I had IIS 5.0 instead of IIS 4.0 when I start ASP I might of done my site differently, but I am happy with this way. It seems to work better FOR ME.
whammy
11-28-2002, 12:25 AM
Bruce Li: "Use what works."
;)
PlatinumProject
11-28-2002, 02:45 AM
so i used this
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
%>
<!--#include file="news.htm"-->
<%
Else
%>
<!--#include file="home.htm"-->
<%
End If
%>
and it works fine but now is there a way the code above can be modified to make other pages be inlude as well...?
if not not i will just use a big <iframe>
o and thanks to all that have tried to slove my problem
Morgoth
11-28-2002, 03:06 AM
This is when you start to use an ElseIf statement inside your If statement.
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
%>
<!--#include file="news.htm"-->
<%
ElseIf Page="OTHER.htm" Then
%>
<!--#include file="OTHER.htm"-->
<%
Else
%>
<!--#include file="home.htm"-->
<%
End If
%>
Adding a ' is like adding a //, it comments out code.
Now you can also do this another way. Try this:
<%
Dim Page
Page = Request.QueryString("page")
If Page <> "" Then ' Page Doesn't = "" ("" = Blank)
Response.Write "<!--#include file=" & Page & ".htm-->"
Else
Response.Write "<!--#include file=home.htm-->"
End If
%>
This will make it so that any page you put in the ?page="" tag will be included. Not a very effecive method if people try to type in their own extention.
Try the first method I posted, or this smaller easier to read (if you know ASP) version of the code. (does the same thing, but this one uses Response.Write)
<%
Dim Page
Page = Request.QueryString("page")
If Page="news.htm" Then
Response.Write "<!--#include file=news.htm-->"
ElseIf Page="OTHER.htm" Then
Response.Write "<!--#include file=OTHER.htm-->"
Else
Response.Write "<!--#include file=home.htm-->"
End If
%>
Good?
PlatinumProject
11-28-2002, 03:11 AM
i will try this one it looks close to php
<%
Dim Page
Page = Request.QueryString("page")
If Page <> "" Then ' Page Doesn't = "" ("" = Blank)
Response.Write "<!--#include file=" & Page & ".htm-->"
Else
Response.Write "<!--#include file=home.htm-->"
End If
%>
if i'm right than i can take out the
<%
Dim Page
Page = Request.QueryString("page")
If Page <> "" Then ' Page Doesn't = "" ("" = Blank)
Response.Write "<!--#include file=" & Page & ".htm -->"
Else
Response.Write "<!--#include file=home.htm-->"
End If
%>
and it will load any file with any extension
or am i wrong?
PlatinumProject
11-28-2002, 03:36 AM
crap it didn't work
PlatinumProject
11-28-2002, 03:37 AM
o well i guess i will just us on old fashion <iframe>
Morgoth
11-28-2002, 04:58 AM
<%
Dim Page
Page = Request.QueryString("page")
If Page <> "" Then ' Page Doesn't = "" ("" = Blank)
Response.Write "<!--#include file=" & Page & ".htm-->"
Else
Response.Write "<!--#include file=home.htm-->"
End If
%>
This way works, and you can change the .htm to what ever you want!
I don't see why you need an iframe.
Contact me through e-mail and tell me exact what you need and I will enter your account folder and change it with my magical admin powers. You will have it running perfect.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.