Hi Simon,
I would recommend reading up on Object-Oriented programming. The paradigm
for OOP is entirely different from procedural programming, and unless you
understand the principles, you will continually be confounded. ASP is
procedural, meaning that the programming instructions contained in an ASP
page/script are executed in the order in which they appear in the
script/page, including the rendering of HTML in the page. ASP.Net is
Object-oriented, meaning that programming instructions are not in a script
and are not executed sequentially. Therefore, there is no such thing as a
"global function." There is Scope, but Scope is defined differently. Rather
than functions that are simply defined and called as needed, there are
classes, which are aggregates of data and functionality bundled together in
an encapsulation. The class is a container, if you will, for these various
functions and data. It doesn't execute in the procedural sense, but behaves
more like an object which can be used by another object.
The term "global," and the concept of Scope in general, are different.
Members of a class are "global" to the class; that is, they are accessible
to all class members. A class can have members that are not available
outside of the class, or to any class which doesn't inherit the class, or
are visible to any entity outside of the class. These members are scoped as
Private, Public, Protected, etc. In addition, you have the same general
types of scope that exist in an ASP application, such as the Application,
which is globally available to all classes in the application, Session,
which is global to all page instances of a single user, and so on.
Again, as ASP.Net is not procedural, it is not hepful to think of functions,
classes, and other programming objects as being "in files." ASP.Net is not
scripted, but compiled. Classes and other programming elements reside in
NameSpaces, and in assemblies. The files are simply a storage container for
the code. The file is not important; the code is. Object-oriented
programming is a good bit more abstract than procedural, but once you start
thinking object-oriented, it all snaps neatly into place.
In any case, you should be able to see now that a basic understanding of
Object-Oriented programming principles is essential to writing an ASP.Net
application.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.