Dynamic Inlcude 
Author Message
 Dynamic Inlcude

using the following bit of code (psudo)

<A href="ts.asp?rd=1">Navigate this Site</A>

ts.asp :

<%
    rd = Request.QueryString("rd")
    Select Case rd
    case 1
     redirectfile = "navigate.inc"
   case 2
    redirectfile = "search.inc"
      end select
%>
<%
If redirectfile = "" then
%>

'Problem is with the include ... Can i dynamically include ... cos i have an
incliing i cant as it must process the include file before it includes it on
to the parent page

<!-- #Include file="<%=redirectfile%>" -->

<%
End If
%>

--

================================
Phil Winstanley
Metcom Integrated Services

www.misltd.co.uk
================================



Sun, 09 Mar 2003 03:00:00 GMT  
 Dynamic Inlcude

If you are using IIS 5.0, you can now do dynamic includes with either the Server.Transfer or
Server.Execute methods.  The file included will have access to the intrinsic ASP objects, but not
variables dimensioned on the calling page.  I also found a bug with this in that the Server.Execute
method will not execute on a path that includes a virtual directory.  These features are brand new
in IIS 5.0, and consequently are not well documented.

The other way to accomplish this is to stick the code from the include files into subroutines and
then call the sub routines based on your case.  This makes for spaghetti code.

You could also have two separate asp pages and perform a Response.Redirect to one of those pages
based on the case.

I have used all three and they all have drawbacks, but the third one is probably your best bet.  It
allows for more atomic ASP pages and it is backwards compatible with IIS 4.0.  I hope this helps.

Mike Olson

using the following bit of code (psudo)

<A href="ts.asp?rd=1">Navigate this Site</A>

ts.asp :

<%
    rd = Request.QueryString("rd")
    Select Case rd
    case 1
     redirectfile = "navigate.inc"
   case 2
    redirectfile = "search.inc"
      end select
%>
<%
If redirectfile = "" then
%>

'Problem is with the include ... Can i dynamically include ... cos i have an
incliing i cant as it must process the include file before it includes it on
to the parent page

<!-- #Include file="<%=redirectfile%>" -->

<%
End If
%>

--

================================
Phil Winstanley
Metcom Integrated Services

www.misltd.co.uk
================================



Sun, 09 Mar 2003 03:00:00 GMT  
 Dynamic Inlcude
Yes Thanks, help is muchly appreciated - even if its still an artse to fix
hehe :o) i got round it with a bit of code mind :

this on the page

<% If Session("introduction") = "True" Then%> <!-- #Include file =
"forms/introduction.asp" -->
<%End IF%>
<% If Session("free") = "True" Then%> <!-- #Include file =
"forms/free.asp" -->
<%End IF%>
<% If Session("help") = "True" Then%> <!-- #Include file =
"forms/help.asp" -->
<%End IF%>
<% If Session("legal") = "True" Then%> <!-- #Include file =
"forms/legal.asp" -->
<%End IF%>
<% If Session("membership") = "True" Then%> <!-- #Include file =
"forms/membership.asp" -->
<%End IF%>
<% If Session("navigate") = "True" Then%> <!-- #Include file =
"forms/navigation.asp" -->
<%End IF%>
<% If Session("post") = "True" Then%> <!-- #Include file =
"forms/post.asp" -->
<%End IF%>
<% If Session("live") = "True" Then%> <!-- #Include file =
"forms/live.asp" -->
<%End IF%>
<% If Session("search") = "True" Then%> <!-- #Include file =
"forms/search.asp" -->
<%End IF%>
<% If Session("services") = "True" Then%> <!-- #Include file =
"forms/services.asp" -->
<%End IF%>

And this on the inbetween page

<%
 Session("help") = "False"
 Session("introduction") = "False"
 Session("legal") = "False"
 Session("live") = "False"
 Session("membership") = "False"
 Session("navigate") = "False"
 Session("post") = "False"
 Session("search") = "False"
 Session("services") = "False"
 Session("free") = "False"

 Session("free") = "True"
 Session("PageTitle") = "Free Online Membership"
 Response.Redirect("../tenantscan.asp")
%>


Quote:
> If you are using IIS 5.0, you can now do dynamic includes with either the
Server.Transfer or
> Server.Execute methods.  The file included will have access to the

intrinsic ASP objects, but not
Quote:
> variables dimensioned on the calling page.  I also found a bug with this

in that the Server.Execute
Quote:
> method will not execute on a path that includes a virtual directory.

These features are brand new
Quote:
> in IIS 5.0, and consequently are not well documented.

> The other way to accomplish this is to stick the code from the include

files into subroutines and
Quote:
> then call the sub routines based on your case.  This makes for spaghetti
code.

> You could also have two separate asp pages and perform a Response.Redirect

to one of those pages
Quote:
> based on the case.

> I have used all three and they all have drawbacks, but the third one is

probably your best bet.  It
Quote:
> allows for more atomic ASP pages and it is backwards compatible with IIS

4.0.  I hope this helps.
Quote:

> Mike Olson




Quote:
> using the following bit of code (psudo)

> <A href="ts.asp?rd=1">Navigate this Site</A>

> ts.asp :

> <%
>     rd = Request.QueryString("rd")
>     Select Case rd
>     case 1
>      redirectfile = "navigate.inc"
>    case 2
>     redirectfile = "search.inc"
>       end select
> %>
> <%
> If redirectfile = "" then
> %>

> 'Problem is with the include ... Can i dynamically include ... cos i have
an
> incliing i cant as it must process the include file before it includes it
on
> to the parent page

> <!-- #Include file="<%=redirectfile%>" -->

> <%
> End If
> %>

> --

> ================================
> Phil Winstanley
> Metcom Integrated Services

> www.misltd.co.uk
> ================================



Mon, 10 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamically inlcude ASP pages

2. Dynamic Data Structures: Dynamic Arrays?

3. dynamic forms inside dynamic tables

4. Form Dynamic property , app Dynamic property ?

5. Accessing Dynamic Controls on Dynamic Forms

6. Dynamic SQL Queries, dynamic reports

7. Dynamic ADO Recordset Not Dynamic (Does Not Refresh Data)

8. Dynamic ADO Recordset Not Dynamic (Does Not Refresh Data)

9. Dynamic set frame size

10. VbScript / html dynamic web tree

11. creating dynamic pdf using VBScript?

12. Dynamic Lists

 

 
Powered by phpBB® Forum Software