Current location: Hot Scripts Forums » Programming Languages » ASP » Calling include dependant on url


Calling include dependant on url

Reply
  #1 (permalink)  
Old 08-16-04, 05:21 AM
jonathen's Avatar
jonathen jonathen is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Essex, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Calling include dependant on url

Hi,

Is there a way that I can display certain text within an asp file dependant on the url? This is what I am trying to do:

In default.asp, if the url is default.asp?VariableHere, then the body of default.asp contains an include calling "VariableHere.inc" (replace VariableHere with the name of the include)

Any help is greatly appreciated.

Thanks,

Jonathen
Reply With Quote
  #2 (permalink)  
Old 08-16-04, 06:48 AM
chirag's Avatar
chirag chirag is offline
Newbie Coder
 
Join Date: May 2004
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Angry

Hi,

You can not have variable in the name of include file.
Because inc files are loaded before asp starts execution. So, no asp variables are available at that time.

You can do instead...

if request.querystring("VariableHere.inc" ) = x then
include x.inc
else
include y.inc
end if
Reply With Quote
  #3 (permalink)  
Old 08-16-04, 08:26 AM
jonathen's Avatar
jonathen jonathen is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Essex, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

Thanks for your input - I used a case instead:
Code:
Code:
<% Dim whichpage 
whichpage = Request.QueryString("page") 
Select Case whichpage 
Case "default" %> 
<!-- #include file="default.asp" --> 
<% Case "main" %> 
<!-- #include file="main.asp" --> 
<% Case "admin" %> 
<!-- #include file="admin.asp" --> 
<% Case Else %> 
<!-- #include file="default.asp" --> 
<%End Select%>
...and so on. However, I still have one problem - if the page called is default.asp?page=main, for example, then the correct content from the corresponding "main.asp" is displayed. This is great, but if I just call the page by it's root - default.asp - then no content is displayed, obviously because I have not told it to display some data. However, i cannot seem to get an elseif statement to display some default text if the url is NOT default.asp?page=whatever.
Reply With Quote
  #4 (permalink)  
Old 08-16-04, 08:47 AM
jonathen's Avatar
jonathen jonathen is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Essex, UK
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Ignore that last message - I realised (doh!) I can use the if else statement alongside my case. Thanks for all your help.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random PHP include brduran PHP 4 08-16-04 06:34 AM
iframe linking not working under url masking willNoClue HTML/XHTML/XML 1 08-02-04 10:34 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
How do I include external script jimpy ASP 3 05-24-04 06:39 AM
Banned URL Array optix PHP 14 04-16-04 03:26 AM


All times are GMT -5. The time now is 03:00 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.