Imports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I put
imports xxx.ModuleName
at the top of my asp.net page vb code, does this create an instance of the
imported module that is unique to the page or does it just allow shared
access to the module's functions?
cheers,
jsale
 
Imports is just a notation that instructs the compiler to look into a
particular namespace when a name is found that doesn't seem to belong to the
"current" namespace.
It doesn't do "things" like creating an instance of a module.

It looks like what you are looking is that a module is actually a class with
shared members (my personal preference would be to use this instead, you
loose just the ability to call its members wihtout appending the class name
before)...
 
if i made the module into a class and instanced it on each page that uses the
functions, would i be right in saying that there is no real way data could be
'leaked' between users?
you may remember me from some session questions last week - i'm still having
problems with the information appearing on different users' screens and my
main thought is that using the modules, they;re not instanced at any point,
therefore if more than one user is using them at once, there could be leakage
and errors. maybe... :)
cheers for the information patrice :)
 
Imports doesn't instantiate any modules/types. Its just for type name
resolution only. It has effect only in the included page.

If I put
imports xxx.ModuleName
at the top of my asp.net page vb code, does this create an instance of the
imported module that is unique to the page or does it just allow shared
access to the module's functions?
cheers,
jsale
 
Actually the problme is that shared members (either as members of a class or
implicitely in a module are "shared" by the whole application and an ASP.NET
site is a single application.
As a result, users are sharing the same variables.

You shouldn't use modules or a class with shared members. use a class and
instantie this class for each user so that they have each their own copy...

Patrice

--
 
Back
Top