F
fd123456
Hi Tom !
Sorry about the messy quoting, Google is playing tricks on me at the
moment.
I had never thought of it that way. I'm not saying you're wrong, to be
honest I'm not at all sure, but :
1) I've searched hi and lo and can't find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that's
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don't have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There's no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It's supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!
So, I do believe it's not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.
You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that's IIS working under the
scene). You don't have to inherit it on any page, because the
structure is as follows :
Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that's named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don't need to inherit
from the application itself (read : they musn't).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.
You don't. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that's why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).
Well, that's very good news for you, because I'm positive that it'll
all become clear very quickly, and I'm also quite sure that you'll
have tremendous fun. VS is the best toy I ever dreamed of, it's fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I've developped a program that used to cost around
100.000 $ five years ago. I'm in no way affiliated blah blah,
obviously.
So, have fun with it !
Michel
Sorry about the messy quoting, Google is playing tricks on me at the
moment.
Global.asax is where you normally have the Global Application
and Session variables and code to manipulate them. It starts
and ends with <script></script> tags.
Yours looks like a compiled version of it.
It is just like any ASP.net page. If you use code-inside, you
surround the code with the script tags. To make the code into
a code-behind file, you move the code to a new file and leave
out the script tags.
I had never thought of it that way. I'm not saying you're wrong, to be
honest I'm not at all sure, but :
1) I've searched hi and lo and can't find anything resembling script
tags in Global.asax.
2) There has to be a Global shared (static) class, because that's
where the variables are held.
3) In VS, contrarily to plain aspx pages, you don't have access to
HTML code for Global.asax (usually, an aspx combo has three different
views : the html view and the design view, which are two tabs on the
same window, and the code-behind file which sits in another window.
There's no design or html tab in Global.asax.
4) As far as I know, aspx stands for Active Server Page eXtended(?),
asax stands for Active Server Application eXtended(?). It's supposed
to be an app, not an page as such. You cannot, for instance, drop a
html table on Global.asax, but mind you, you can drop Windows Forms
controls on it !!
So, I do believe it's not an aspx but a proper app, contained in a
class, and not enclosed in a script block. Again, I could be wrong. I
wish some guru would help us there.
To have a class, I think you would need to compile the file, as you said
and you would have to have the codebehind/inherits on all my pages. I am
trying to get around this.
You definitely need to compile the file in any case. Compiling it
creates a dll in a bin directory, without which no aspx page can be
served (plain html can, though, but that's IIS working under the
scene). You don't have to inherit it on any page, because the
structure is as follows :
Global.asax inherits from the System.Web.HttpApplication class and is
inside the namespace that's named after your project. As it is shared,
it can be used from any other object that is inside that namespace, so
any page inside that namespace can refer to Global.asax simply by
using, for instance, "Global.SomeMethod" (provided that method is
public, obviously).
Pages inherit from System.Web.Ui class. They don't need to inherit
from the application itself (read : they musn't).
Each page has an associated code-behind file, and the aspx file
inherits from the class that lies in the code-behind file. With VS,
all this is totally transparent and taken care for you by the
Framework.
The other problem is - how would I handle 2 codebehind files. Each
aspx page would have it's own code behind and then you have the
Global one. How would you set that up in your ASP pages (you would
need 2 inherits and 2 codebehind statements).
You don't. Again, I think your misconception comes from the fact that
you think the app is not compiled. Think of it this way : the app
contains many classes, some being pages, some being code-behind files,
and one being the Global object. All these classes can (theoretically)
talk to each other, and that's why, to return to the beginning of your
question, you can include shared methods in the Global class and use
them from other classes (code-behind files).
I did that last night, as you suggested, and just have to wait for the CD.
Well, that's very good news for you, because I'm positive that it'll
all become clear very quickly, and I'm also quite sure that you'll
have tremendous fun. VS is the best toy I ever dreamed of, it's fast,
deep, smart, coherent and has the most impressive optimisations. In a
month and a half, I've developped a program that used to cost around
100.000 $ five years ago. I'm in no way affiliated blah blah,
obviously.
So, have fun with it !
Michel