A
Alan Silver
Hello,
I have spent ages trawling through Google, looking for information about
global functions in ASP.NET and I'm still not clear about the best way
to go about this (or not).
I am writing a site that will be for members only. They will have to log
in to gain access to any of the pages. I am holding the user information
in an XML file (there will probably never be a large number of user, so
this is efficient enough).
What I would like to do is have a global function that I can use to get
user settings out of the XML file. For example, if I called ...
UserSettings("accessLevel")
then I would get the access level setting for the currently logged in
user (where "accessLevel" is something I put in the XML file).
After researching this, two main points seem to come up over and over
again...
1) To use global functions, create a class and add the functions in
there. If they are static, then you don't need to instantiate the class,
you just call MyStuff.UserSettings("accessLevel").
2) Don't have global functions, it's not the OOP way.
The problems I have are (in relation to these two points)...
1) OK, so I can create a file called MyStuff.cs, which contains a class
and the static members. What do I do with it then? I guess if you are
using VS, then that's all you need to do, but I'm using a text editor.
What do I do with the .cs file when I've created it? No-one seems to
mention that point.
2) What's a better (ie more OOP) way to do this? I'm very keen to learn
the right way to do things, but I can't see one here.
Any advice appreciated.
I have spent ages trawling through Google, looking for information about
global functions in ASP.NET and I'm still not clear about the best way
to go about this (or not).
I am writing a site that will be for members only. They will have to log
in to gain access to any of the pages. I am holding the user information
in an XML file (there will probably never be a large number of user, so
this is efficient enough).
What I would like to do is have a global function that I can use to get
user settings out of the XML file. For example, if I called ...
UserSettings("accessLevel")
then I would get the access level setting for the currently logged in
user (where "accessLevel" is something I put in the XML file).
After researching this, two main points seem to come up over and over
again...
1) To use global functions, create a class and add the functions in
there. If they are static, then you don't need to instantiate the class,
you just call MyStuff.UserSettings("accessLevel").
2) Don't have global functions, it's not the OOP way.
The problems I have are (in relation to these two points)...
1) OK, so I can create a file called MyStuff.cs, which contains a class
and the static members. What do I do with it then? I guess if you are
using VS, then that's all you need to do, but I'm using a text editor.
What do I do with the .cs file when I've created it? No-one seems to
mention that point.
2) What's a better (ie more OOP) way to do this? I'm very keen to learn
the right way to do things, but I can't see one here.
Any advice appreciated.