View Full Version : Query String

03-31-2007, 01:49 AM
Just curious. I have a website currently that has query strings to load individual pages, like this

$main = $_GET['page'];

if($main == 'history'){
} else if($main == 'contact'){
} else{ include_once('main.php');

How would I obtain the same simple functionality with ASP?


03-31-2007, 03:46 PM
I've not used ASP for years, but I guess it goes something like this

dim page
If Request.QueryString<>"" Then
If Request.QueryString("page")<>", " Then
<!--#include file=""&page&".inc"-->
end if
end if

I wasn't that far off I don't think, just did a search for you

Dim whichpage
whichpage = Request.QueryString("page")
If whichpage = "" Then
whichpage = "default"
<!-- #include file="<%= whichpage %>.asp" -->
<%End If %>

Grant Palin
04-01-2007, 12:23 AM
I don't think you can use a variable in a page name like that. Unfortunately, Classic ASP requires you to hard code the include names - you can't build it from a variable like that.

04-01-2007, 04:03 PM
You can however include a different include file by putting the include file into the If/Then statement like so

Dim whichpage
whichpage = Request.QueryString("page")
If whichpage = "history" Then
<!-- #include file="history.asp" -->
<%ElseIf whichpage="contact" Then %>
<!-- #include file="contact.asp" -->
<!-- #include file="main.asp" -->
<%End If %>

04-18-2007, 04:22 PM
If these are file on the file system - as apposed to database records - then you can use server execute to load the files