...

View Full Version : Query String



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



<?php
$main = $_GET['page'];

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

How would I obtain the same simple functionality with ASP?

Thanks

Nightfire
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
page=Request.QueryString("page")
<!--#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.

miranda
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" -->
<%Else%>
<!-- #include file="main.asp" -->
<%End If %>

degsy
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

http://computer-helpforum.com/asp/aspfree/included_content/Server_Execute/default.asp



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum