Module in ASP.NET 2.0

I

Iouri

I am using VS 2005 team edition. I cannot find Module in ASP.NET 2.0. It is
not in the list of Visual Studio installed templates. Where is it? or what
can I use to hold my global variables and Subs accessible from different
pages.
I tried to add class and make it Shared, but I am getting an error message
that classes cannot be declared Shared.
Also VS does not let me declare shaered constants in a class.
I need to use the same sub from different pages.
Does somebody have a solution for that?
Thank you
 
G

Guest

1. Add App_Code folder
2. Add class file (Globals.vb)
3. Search and replace Class with Module

You now have a module without a problem and it looks like this:

Imports Microsoft.VisualBasic

Public Module Globals
'Implementation here
End Module

This is not necessary, even for "global" variables, however, as you can set
up global configurations in the config file or create your own "config"
object with Shared members (fields and/or properties) and methods. The only
thing Module does for you is force the compiler to share all of the bits in
the class (er, Module) without you having to declare them as Shared (ie, it
saves a small bit of typing while obfuscating meaning ;->).


Public Class Globals2

Private Sub New()
'Make sure it cannot be instantiated
End Sub

Public Shared MagicNumber As Integer= 42

End Class

This serves the same purpose as the Module below, with a few extra keystrokes

Public Module Globals

Public MagicNumber As Integer = 42

End Module

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
I

Iouri

Thank you very much. It did the trick

Cowboy (Gregory A. Beamer) - MVP said:
1. Add App_Code folder
2. Add class file (Globals.vb)
3. Search and replace Class with Module

You now have a module without a problem and it looks like this:

Imports Microsoft.VisualBasic

Public Module Globals
'Implementation here
End Module

This is not necessary, even for "global" variables, however, as you can
set
up global configurations in the config file or create your own "config"
object with Shared members (fields and/or properties) and methods. The
only
thing Module does for you is force the compiler to share all of the bits
in
the class (er, Module) without you having to declare them as Shared (ie,
it
saves a small bit of typing while obfuscating meaning ;->).


Public Class Globals2

Private Sub New()
'Make sure it cannot be instantiated
End Sub

Public Shared MagicNumber As Integer= 42

End Class

This serves the same purpose as the Module below, with a few extra
keystrokes

Public Module Globals

Public MagicNumber As Integer = 42

End Module

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Joined
Oct 26, 2009
Messages
1
Reaction score
0
Modules being used for AL

Make your class into module using this notes

1. Add App_Code folder
2. Add class file (Globals.vb)
3. Search and replace Class with Module

You now have a module without a problem and it looks like this:

Imports Microsoft.VisualBasic

Public Module Globals
'Implementation here
End Module

This is not necessary, even for "global" variables, however, as you can set
up global configurations in the config file or create your own "config"
object with Shared members (fields and/or properties) and methods. The only
thing Module does for you is force the compiler to share all of the bits in
the class (er, Module) without you having to declare them as Shared (ie, it
saves a small bit of typing


Then try using that module in AL tool

Also note All Visual Studio compilers produce assemblies.
Try creating modules (ie without a manifest) with appropriate options
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top