473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Module in ASP.NET 2.0

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
Dec 29 '05 #1
2 1586
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!
***************************
"Iouri" wrote:
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

Dec 29 '05 #2
Thank you very much. It did the trick

"Cowboy (Gregory A. Beamer) - MVP" <No************@comcast.netNoSpamM> wrote
in message news:D9**********************************@microsof t.com...
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!
***************************
"Iouri" wrote:
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

Dec 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
8
by: Irmen de Jong | last post by:
What would be the best way, if any, to obtain the bytecode for a given loaded module? I can get the source: import inspect import os src = inspect.getsource(os) but there is no...
5
by: dody suria wijaya | last post by:
I found this problem when trying to split a module into two. Here's an example: ============== #Module a (a.py): from b import * class Main: pass ============== ==============
3
by: David T. Ashley | last post by:
Hi, Red Hat Enterprise Linux 4.X. I'm writing command-line PHP scripts for the first time. I get the messages below. What do they mean? Are these operating system library modules, or...
10
by: Bonzol | last post by:
vb.net Hey there, could someone just tell me what the differnce is between classes and modules and when each one would be used compared to the other? Any help would be great Thanx in...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
40
by: rjcarr | last post by:
Sorry if this is a completely newbie question ... I was trying to get information about the logging.handlers module, so I imported logging, and tried dir(logging.handlers), but got: ...
4
by: rkmr.em | last post by:
Hi I have a function data, that I need to import from a file data, in the directory data If I do this from python interactive shell (linux fedora core 8) from dir /home/mark it works fine: ...
0
by: Fredrik Lundh | last post by:
Jeff Dyke wrote: so how did that processing use the "mymodulename" name? the calling method has nothing to do with what's considered to be a local variable in the method being called, so...
6
by: dudeja.rajat | last post by:
Hi, I found on the net that there is something called module initialization. Unfortunately, there is not much information for this. However, small the information I found module initialization...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.