|
 |
asp_web_howto thread: Global Includes
Message #1 by "Brice Mason" <bricemason@h...> on Mon, 7 Oct 2002 20:11:21
|
|
Hello,
I am a ColdFusion developer looking to learn more about ASP. It seems as
though the global.asa file is similar in function to the Application.cfm
file. The Application.cfm file is processed before every page in an
application. Therefore, I use it to declare my db connection strings, and
also to display my navigation header for the application. This helps keeps
things in one place making adjustments easy. How do I do this in ASP?
Thanks in Advance,
Brice Mason
Message #2 by "Scott Dempsey" <scottd@c...> on Mon, 7 Oct 2002 15:31:37 -0700
|
|
HI Brice,
As a big fan of not re-inventing the wheel, why not just add these
components as Server Side Includes?
On each page, add lines like:
<!-- #include virtual="DBConection.asp" -->
<!-- #include virtual="NavBar.asp" -->
Then have a couple of files that contain the germaine code.
- Scott
-----Original Message-----
From: Brice Mason [mailto:bricemason@h...]
Sent: Monday, October 07, 2002 8:11 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Global Includes
Hello,
I am a ColdFusion developer looking to learn more about ASP. It seems as
though the global.asa file is similar in function to the Application.cfm
file. The Application.cfm file is processed before every page in an
application. Therefore, I use it to declare my db connection strings,
and
also to display my navigation header for the application. This helps
keeps
things in one place making adjustments easy. How do I do this in ASP?
Thanks in Advance,
Brice Mason
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #3 by "Ken Schaefer" <ken@a...> on Tue, 8 Oct 2002 11:12:36 +1000
|
|
The global.asa file contains various event handlers that handle the
following events;
a) Application_OnStart (when the first page is ever requested from your
application)
b) Application_OnEnd (a bit buggy - doesn't fire properly on older IIS)
c) Session_OnStart (when a particular user first accesses your site)
d) Session_OnEnd (when the user's session times out, or session.abandon is
called)
So, you can initialise global constants in your global.asa file. For
example, when your application first starts, you could set a variable to
hold the value of your database connections string
Sub Application_OnStart
Application("DBConnString") = _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Initial Catalog=Pubs;Data Source=MyMachine;"
End Sub
then you can use Application("DBConnString") wherever you want in your app.
For storing common code snippets, I would put the stuff into it's own file,
and use a server-side include (SSI) to include the code into your page. SSI
is a platform agnostic standard.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Brice Mason" <bricemason@h...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, October 07, 2002 8:11 PM
Subject: [asp_web_howto] Global Includes
: Hello,
:
: I am a ColdFusion developer looking to learn more about ASP. It seems as
: though the global.asa file is similar in function to the Application.cfm
: file. The Application.cfm file is processed before every page in an
: application. Therefore, I use it to declare my db connection strings, and
: also to display my navigation header for the application. This helps keeps
: things in one place making adjustments easy. How do I do this in ASP?
:
: Thanks in Advance,
:
: Brice Mason
:
: ---
:
: Improve your web design skills with these new books from Glasshaus.
:
: Usable Web Menus
: http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
: r-20
: Constructing Accessible Web Sites
: http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
: r-20
: Practical JavaScript for the Usable Web
: http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
: r-20
Message #4 by "Brice Mason" <bricemason@h...> on Tue, 8 Oct 2002 13:01:36
|
|
Hello Again,
I see where this is good for declaring global connection strings, with the
SSI, can I use "Response.Write" or even just straight HTML to display a
navigation header for the application? I have tried to use a straight asp
page as an include in global.asa but it is not being processed. Any more
help you could offer is greatly appreciated.
Thanks,
Brice
> The global.asa file contains various event handlers that handle the
following events;
a) Application_OnStart (when the first page is ever requested from your
application)
b) Application_OnEnd (a bit buggy - doesn't fire properly on older IIS)
c) Session_OnStart (when a particular user first accesses your site)
d) Session_OnEnd (when the user's session times out, or session.abandon is
called)
So, you can initialise global constants in your global.asa file. For
example, when your application first starts, you could set a variable to
hold the value of your database connections string
Sub Application_OnStart
Application("DBConnString") = _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Initial Catalog=Pubs;Data Source=MyMachine;"
End Sub
then you can use Application("DBConnString") wherever you want in your app.
For storing common code snippets, I would put the stuff into it's own file,
and use a server-side include (SSI) to include the code into your page. SSI
is a platform agnostic standard.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Brice Mason" <bricemason@h...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, October 07, 2002 8:11 PM
Subject: [asp_web_howto] Global Includes
: Hello,
:
: I am a ColdFusion developer looking to learn more about ASP. It seems as
: though the global.asa file is similar in function to the Application.cfm
: file. The Application.cfm file is processed before every page in an
: application. Therefore, I use it to declare my db connection strings, and
: also to display my navigation header for the application. This helps
keeps
: things in one place making adjustments easy. How do I do this in ASP?
:
: Thanks in Advance,
:
: Brice Mason
:
: ---
:
: Improve your web design skills with these new books from Glasshaus.
:
: Usable Web Menus
: http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
: r-20
: Constructing Accessible Web Sites
: http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
: r-20
: Practical JavaScript for the Usable Web
: http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
: r-20
Message #5 by "Ken Schaefer" <ken@a...> on Wed, 9 Oct 2002 11:34:21 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Brice Mason" <bricemason@h...>
Subject: [asp_web_howto] Re: Global Includes
:, with the
: SSI, can I use "Response.Write" or even just straight HTML to display a
: navigation header for the application? I have tried to use a straight asp
: page as an include in global.asa but it is not being processed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yes, you can do what you are asking for. How are you "including" the file?
<% @Language=VBScript%>
<!-- #include virtual="/includes/myinclude.asp" -->
<%
' Other ASP Code here
%>
will work just fine. What happens is that everything in myinclude.asp is
"pasted" into the current page where the include directive is, and then all
the ASP code in the current page is procesed.
Cheers
Ken
|
|
 |