Application wide Functions and Connections

  • Thread starter Thread starter Thomas
  • Start date Start date
T

Thomas

Hi,

I want to share a function in an application, so that in global asax or
pages can use that function like:

Dim sMyVariable = MyApplication.GetSomething("SomeKey")

How do I access a global application instance?

Is it advisable to store database connections in a global application
instance, and expose them as Properties eg

Dim sMyVariable = MyApplication.MyConnection.ExecuteNonQuery()?
Dim sMyOtherVariable = MyApplication.MyOtherConnection.ExecuteNonQuery()?

Thomas
 
Hi Scott,

Thanks that was useful.

Can you also tell me how to access a Global.MyVariable in a aspx code block
eg mypage.aspx: <%=Global.MyVariable%>?

Thanks!

Thomas
 
First, add the namespace where the Global class resides into the aspx
file:

<%@ Import namespace="..." %>

Then reference the properties inside script blocks:

<% Response.Write(Global.MyVariable); %>

Hope this helps,
 
Back
Top