I have
made a small break through with ASP.Net on being able to use an master switch
file and a single layout file.
Since
ASP.Net has two ways of including outside code, the first which is only kept for
backwards compatibility is the standard server executes, and second which is
included with .Net User Controls. Now I do not remember everything about
the user controls, as I know there is a way to dynamically include them and I
have to re-look that one up. But here is a simple example that allows you
to have one layout file and a separate switch/fusebox
control
create
a user control, name it whatever you want, for my example I am using
fb_switch.ascx
In
this file create a switch statement, or select case statement, depending on the
language you are using in the html view. For example here is a little code
snippet
<%Control Language="vb" AutoEventWireup="false"
CodeBehind="fb_switch.ascx.vb" %>
<%
Select Case Request.QueryString("fuseaction")
Case "welcome" %>
<%@ Register tagprefix="FA"
Tagname="Welcome" Src="dsp_welcome.ascx" %>
<FA:Welcome runat="server"
/>
<% End Select %>
Then
create a user control called dsp_welcome.ascx for the sole purpose of displaying
our little message of; you guessed it, "Hello World"
<%Control
Language="vb" AutoEventWireup="false" CodeBehind="dsp_welcome.ascx.vb"
%>
Hello World!
Finally create your layout as a standard index.aspx file, and in the
location(s) you would like to use the switch file:
<%@
Register TagPrefix="FA" TagName="Switch" Src="fb_switch.ascx"
%>
<%@
Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb"
%>
<HTML>
<HEAD>
<TITLE>Fusebox test in
ASP.Net</TITLE>
</HEAD>
<BODY>
<FA:Switch runat="server"
/>
</BODY>
</HTML>
That
is all that is to it for a simple version. I will work on a more complex
example later on, but this was one of the things I was trying to figure out how
to do, and I figured it out.
Just
thought I share this info. I will let you know an example for dynamic fa_
files after I find my source that helps me include dynamic user controls.
-----Original Message-----
From: Robert Everland [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 11:30 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Idea for Dynamic Includes in ASP FuseBoxDoes anyone know if .Net allows dynamic includes? And does anyone know why ASP doesn't allow dynamic includes? Was it they never though they would need it, or is it an issue with the language all togethe?Robert Everland III
Dixon Ticonderoga
Web Developer Extraordinaire-----Original Message-----Steve,
From: Douglas Smith [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 11:25 AM
To: [EMAIL PROTECTED]
Subject: Re: Idea for Dynamic Includes in ASP FuseBox
Yes, that would not work with regular SSI includes, *but* it might work in asp with if you use the list of includes to dynamically wrote out the fa_ file as a separate (temp) file, then executed it with server.execute. I wonder how much writing to a file on each request would slow down execution...does not seem much better than actually having pre-existing fa_ files. However, this is beginning to sound a little like Bjork's idea of a pre-processor for ASP....Hmm... conceivable, you could have a separate "road map" file that "compiles" all the fa_ files for you, if you wanted....That way you have the best of both worlds: a unified roadmap/compiler file and separate fa_ files (which are needed in ASP for scalable execution with server.execute)
Just a crazy idea...probably going off the deep end here....time to stop theorizing, and find time to work through some real world examples and demos...
At 12:44 PM 3/21/02 -0500, you wrote:
oh wait, this idea won't work. you can't do dynamic includes in ASP. Damn you Gates!! Damn you! :-)
Steve
Steve Nelson wrote:
That's an interesting idea and gives me an idea that may or may not simplify it... How about this... Instead of actually including the files in the switch statement, you simply create a list of fuses to include, then loop through the list after the switch? i don't know ASP, but here is the cf for what i'm talking about:
<cfset includelist="">
<cfswitch expression=#attributes.fuseaction#>
<cfcase value="fuseaction1">
<cfset includelist=listappend(includelist,"qry_fuse1.cfm")>
<cfset includelist=listappend(includelist,"dsp_fuse1.cfm")>
</cfcase>
<cfcase value="fuseaction2">
<cfset includelist=listappend(includelist,"qry_fuse2.cfm")>
<cfset includelist=listappend(includelist,"qry_fuse3.cfm")>
<cfset includelist=listappend(includelist,"dsp_fuse4.cfm")>
</cfcase>
</cfswitch>
<cfloop list="#includelist#" index="fuse">
<cfinclude template="#fuse#">
</cfloop>
Steve
Douglas Smith wrote:
Hey fellow ASP fuseboxers,
I just got this idea on how to manage dynamic includes in ASP Fusebox. It may be a little untimely, with ASP.Net coming out and all, but I think it is still relevant for all those supporting existing ASP web sites. FYI, I cross-posted to [EMAIL PROTECTED], but I think there are enough people on this listed interested to make it worth posting here.
FYI, this is an FB2 solution, not an FB3 solution.
The main problem with ASP FuseBox is that standard server side includes are not dynamic (large index files with lots of fuseactions really slow down ASP fusebox web sites), and the only other way to do something similar is with server.execute("filename"). But using server.execute, you can't pass local variables in or out of the code you want to run (session and application variables can be passed, but that confuses the scopes, and involves more server memory). But, we really only need to pass local variables between fuses in the same fuseaction, plus have access to the app_locals and app_globals vars, right?
So, why not create a new type of file, with a naming convention like "fus_fuseactionname.asp". Inside this file would be the same fuses that you would otherwise put in the index.cfm, *plus* references to global and/or local variables for the circuit. For example:
Contents of fus_MyFuseAction.asp:<!--#include file="../app_globals.asp"--> <!--#include file="app_locals.asp"--> <!--#include file="qry_myquery.asp"--> <!--#include file="qry_myquery2.asp"--> <!--#include file="dsp_myfuse.asp"-->
Optionally, you would set any XFA's here, if you use them. Basically, anything you do in the Fuseaction, you would do here.
This file would then be called with server.execute, from the index.asp, like so:
Select Case attributes("fuseaction")Case "MyFuseAction" server.execute("fus_MyFuseAction.asp") Case "MyFuseAction2" server.execute("fus_MyFuseAction2.asp") Case Else response.redirect("index.asp")
End Select
The main drawback that I see is that you loose part of the "roadmap" qualities that are inherent in the index.cfm, and you can't see down to the fuse level in the index. Plus you have to manage another set of fusebox files, and include the app_globals/locals for each fuseaction. But you gain dynamic includes with the ability to share local variables between fuses.
Has anybody tried anything like this before? Are there any major drawback that I am missing?
I have not actually tested this methodology yet, but I am excited about the possibilities for implementing the fusebox methodology on larger ASP web sites.
What about a naming convention for this "fuseaction" file? I am currently suggesting using "fus_", but what about "fa_" for "fuseaction", or "fac_" for "fuseaction? Any ideas or preferences?
==^================================================================ This email was sent to: [email protected] EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrFMa.bV0Kx9 Or send an email to: [EMAIL PROTECTED] T O P I C A -- Register now to manage your mail! http://www.topica.com/partner/tag02/register ==^================================================================
