| Author |
Topic Search Topic Options
|
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Topic: Module VS Class Posted: 25 October 2003 at 6:31am |
Hey guys,
I'm building a web application in ASP.NET (..), and have to request quite a few values from cookies. Now, you can't peform any of the Request commands in classes, can you do that in modules?
If not, why should I use a module instead of a class? Look's like they're the same so.. Cause now I have to redirect clients to tons of pages, because they need the QueryString, wich is not really secure and stuff.
So, what is the difference between a module and a class.
|
|
Gone..
|
 |
The WizeGuy
Newbie
Joined: 02 October 2003
Location: Sweden
Status: Offline
Points: 34
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 October 2003 at 4:21pm |
You can do that in Classes!
Dim _ctx As HttpContext = HttpContext.Current Dim _cookVal As String = _ctx.Request.Cookies("CookieName")("CookieKey")
thats about IT!
cya,
/PatrikB
|
 |
The WizeGuy
Newbie
Joined: 02 October 2003
Location: Sweden
Status: Offline
Points: 34
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 October 2003 at 4:22pm |
Diep-Vriezer wrote:
So, what is the difference between a module and a class.
|
NET Framework SDK wrote:
Modules are a reference type similar to classes, but with some important distinctions. The members of a module are implicitly Shared and scoped to the declaration space of the standard module's containing namespace, rather than just to the module itself. Unlike classes, modules can never be instantiated, do not support inheritance, and cannot implement interfaces. A module can only be declared in a namespace and cannot be nested in another type.
You can have multiple modules in a project, but members with the same name defined in two or more modules must be qualified with their module name when accessed outside of their module.
|
cya,
/PatrikB
|
 |
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Posted: 25 October 2003 at 4:22pm |
thx, never thought about that. DUMB.
|
|
Gone..
|
 |
Boecky
Groupie
Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
|
Post Options
Thanks(0)
Quote Reply
Posted: 26 October 2003 at 3:16pm |
So if i understand good... I ALWAYS have to do this when I use a module:
module1.test()
There is no way to import something (module1) that I just can use test() ?
|
 |
Bunce
Senior Member
Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
|
Post Options
Thanks(0)
Quote Reply
Posted: 26 October 2003 at 5:57pm |
You have the answer in your question!
Use the IMPORTS statement at the top of your page, so rather than
in your page, you can do
Cheers, Andrew
|
|
There have been many, many posts made throughout the world...
This was one of them.
|
 |
Diep-Vriezer
Senior Member
Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 October 2003 at 12:42am |
I use this in such cases:
Dim MyClassRefferer As New MyClass
|
EDIT: I should have read your question better, this will still have the MyClassRefferer.Test() req. Use Imports MyClass instead, as described above.
Edited by Diep-Vriezer
|
|
Gone..
|
 |
Boecky
Groupie
Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 October 2003 at 12:46am |
Oh  I thought the import statement was only for classes, but it works also with the modules!
|
 |