Re: Global subroutines
From: tshad (tscheiderich_at_ftsolutions.com)
Date: 02/03/05
- Next message: Alan Silver: "Anyone know when VS 2005 is coming out?"
- Previous message: Fernando Lopes: "Re: RequiredFieldValidator showing an image"
- Maybe in reply to: Stefan Kiryazov (MCAD): "Re: Global subroutines"
- Next in thread: Mark Rae: "Re: Global subroutines"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 3 Feb 2005 08:26:45 -0800
"fd123456" <fd123456@hotmail.com> wrote in message
news:c8d02ef8.0502030448.7b1b5a90@posting.google.com...
> Hi Tom !
>
> 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.
You may be correct.
I know the Global.asax has script tags (only because that was the way the
example program I used a while ago had it set up). In the books I have,
such as "ASP.net: Tips, Tutorials and Code" - it shows it with the script
tags.
Maybe it doesn't matter. Maybe .net just throws it away. I assume that if
you don't have script tags in yours and I do in mine, it isn't an issue with
.net.
>
>> 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.
>
So if I compile it, would I end up with Global.dll?
With a regular code behind, I would compile it like so:
vbc /t:library something.vb
This would give me something.dll.
Would I compile the Global.asax something like:
vbc /t:library Global.asax
To get get Global.dll
Or would I need to name it Global.asax.vb and do:
vbc /t:library Global.dll
>> 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.
>
Should be here soon.
Thanks,
Tom
> So, have fun with it !
>
> Michel
- Next message: Alan Silver: "Anyone know when VS 2005 is coming out?"
- Previous message: Fernando Lopes: "Re: RequiredFieldValidator showing an image"
- Maybe in reply to: Stefan Kiryazov (MCAD): "Re: Global subroutines"
- Next in thread: Mark Rae: "Re: Global subroutines"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|