Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 08-08-2006, 05:58 PM ASP include?
Novice Talker

Posts: 10
Trades: 0
recently just moved from PHP to asp, and I know that in PHP I could write a switch to include files and save it as a php file. When i wanted a page i would just change the id at the end of the url. In the example below, whatever.php?id=1 would display mypage1.php. My question is how does one do this in ASP. I think its possible.

ie.
switch($_GET['id']){

case "page1":
include("mypage1.php");
break;
case "page2":
include("mypage2.php");
break;
case "page3":
include("mypage3.php");
break;
kw91 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-08-2006, 07:06 PM Re: ASP include?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use a select ... case ... construct
Code:
<%
select case lcase(request.querystring("id"))
case "page1"
%>
<!--#include virtual="/page1.asp"-->
<%
case "page2"
%>
<!--#include virtual="/page2.asp" -->
<%
case "page3"
%>
<!--#include virtual="/page3.asp" -->
<%
case else
' this will be executed if no querystring value exists or does not match
%>
<!--#include virtual="/page.asp" -->
<%
end select
%>
Be aware that in ASP includes are parsed before code execution, so if any variable names are duplicated in any of the includes it will throw an error. Common variables should be defined prior to the select statements.
If this creates a problem look at using the server.transfer("page.asp") method in place of the includes.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to ASP include?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38974 seconds with 12 queries