473,769 Members | 7,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global subroutines

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.
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.Http Application 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.SomeMet hod" (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
Nov 19 '05 #1
22 3797
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.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.Http Application 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.SomeMet hod" (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

Nov 19 '05 #2
Hi Tom !
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.
OK, I think I understand now. I opened the Global.asax file with
Notepad, and I have this (and only this):

<%@ Application Codebehind="Glo bal.asax.cs"
Inherits="myNam espace.Global" %>

When I open an aspx page, I get this:

<%@ Page language="c#" Codebehind="myP age.aspx.cs"
AutoEventWireup ="false" Inherits="myNam espace.myPage" %>

So, it is indeed a place where you *can* put script tags. But the
architecture of Visual Studio makes it so you don't. Note the
directives : Global is an "Applicatio n" and pages are "Page"; and the
App has no language specified.
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


Ouch. The problem is, I have never tried to compile anything out of
VS, because it does it automatically (fairly complex site with 30+
auto-configuring pages, 10 databases: 1 keystroke, 2 seconds). But it
doesn't compile as Global.dll, the whole thing is compiled into one
"myNamespace.dl l": all page code-behinds, all classes, Global, all
User Control code-behinds, the works.

So I wouldn't know about the switches. Definitely, this has to do with
Namespaces. It should be compiled as a library, that's for sure, but I
don't know how you go about it. My first guess would be something
like:

vbc /t:library Global.asax.vb myFirstPage.vb mySecondPage.vb
out:myNamespace .dll

If I were you, I'd try this : create one Global.asax containing the
line mentioned above. Create one Global.asax.vb containing :

Imports System.Web
Imports System.Web.Sess ionState

Public Class Global
Inherits System.Web.Http Application

Public Sub New()
MyBase.New()
InitializeCompo nent()
End Sub

Private components As System.Componen tModel.IContain er

<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
End Sub

Public Test() as String
Return "hello";
End Sub
End Class

Create one "TestPage.a spx" containing :

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Tes tPage.aspx.vb" Inherits="myNam espace.TestPage "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server"> </asp:Label>
</form>
</body>
</HTML>

And finally, one TestPage.vb containing:

Public Class TestPage
Inherits System.Web.UI.P age
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Label1.Text = Global.Test
End Sub
End Class

(watch the line feeds)

Then, compile it (unfortunately, I can't help you there) and try
http://localhost/myNamespace/TestPage.aspx.

You might need a Web.config file. If it's the case and you can't wait
for your VS to arrive, just say so and I'll give you a generic one.
But with all this, you should have a proper web app (provided you have
declared your app as a folder in IIS) and a working test page calling
a global routine in the Global class (phew!).

If you manage all this without VS, then I'm in awe.

Another thought : maybe it could help you if I sent you a "blank"
project, containing everything, the project files, the test page and
the global files? If so, just give me your mail adress (don't forget
to put nospam bs in it) and I'll send it to you.

Best of luck !

Michel
Nov 19 '05 #3
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
Hi Tom !
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.
OK, I think I understand now. I opened the Global.asax file with
Notepad, and I have this (and only this):

<%@ Application Codebehind="Glo bal.asax.cs"
Inherits="myNam espace.Global" %>

When I open an aspx page, I get this:

<%@ Page language="c#" Codebehind="myP age.aspx.cs"
AutoEventWireup ="false" Inherits="myNam espace.myPage" %>

So, it is indeed a place where you *can* put script tags. But the
architecture of Visual Studio makes it so you don't. Note the
directives : Global is an "Applicatio n" and pages are "Page"; and the
App has no language specified.
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


Ouch. The problem is, I have never tried to compile anything out of
VS, because it does it automatically (fairly complex site with 30+
auto-configuring pages, 10 databases: 1 keystroke, 2 seconds). But it
doesn't compile as Global.dll, the whole thing is compiled into one
"myNamespace.dl l": all page code-behinds, all classes, Global, all
User Control code-behinds, the works.

So I wouldn't know about the switches. Definitely, this has to do with
Namespaces. It should be compiled as a library, that's for sure, but I
don't know how you go about it. My first guess would be something
like:

vbc /t:library Global.asax.vb myFirstPage.vb mySecondPage.vb
out:myNamespace .dll

If I were you, I'd try this : create one Global.asax containing the
line mentioned above. Create one Global.asax.vb containing :

Imports System.Web
Imports System.Web.Sess ionState

Public Class Global
Inherits System.Web.Http Application

Public Sub New()
MyBase.New()
InitializeCompo nent()
End Sub

Private components As System.Componen tModel.IContain er

<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
End Sub

Public Test() as String
Return "hello";
End Sub
End Class

Create one "TestPage.a spx" containing :

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Tes tPage.aspx.vb" Inherits="myNam espace.TestPage "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server"> </asp:Label>
</form>
</body>
</HTML>

And finally, one TestPage.vb containing:

Public Class TestPage
Inherits System.Web.UI.P age
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Label1.Text = Global.Test
End Sub
End Class

(watch the line feeds)

Then, compile it (unfortunately, I can't help you there) and try
http://localhost/myNamespace/TestPage.aspx.

You might need a Web.config file. If it's the case and you can't wait
for your VS to arrive, just say so and I'll give you a generic one.
But with all this, you should have a proper web app (provided you have
declared your app as a folder in IIS) and a working test page calling
a global routine in the Global class (phew!).

If you manage all this without VS, then I'm in awe.

Another thought : maybe it could help you if I sent you a "blank"
project, containing everything, the project files, the test page and
the global files? If so, just give me your mail adress (don't forget
to put nospam bs in it) and I'll send it to you.


I just got the VS today and will probably not get to it until next week, but
I will try your examples. I need to get a handle on the whole code behind
business.

I just use Dreamweaver and built a couple sites with about 40 or so pages
(that would double of course with code behind).

I'll let you know how I come out.

Thanks,

Tom
Best of luck !

Michel

Nov 19 '05 #4
"tshad" <ts**********@f tsolutions.com> wrote:
I just got the VS today and will probably not get to it until next week, but
I will try your examples. I need to get a handle on the whole code behind
business.
Lucky you ! :)
I just use Dreamweaver and built a couple sites with about 40 or so pages
(that would double of course with code behind).


Actually, it wouldn't, because, all things being equal, the
code-behind belongs to the page itself, so it would still be 40 pages,
each one being comprised of code-afore html and code-behind VB (so to
speak).

I'm sure you'll keep us all posted, because your questions will begin
to flow from next week on :D Have fun!

Michel
Nov 19 '05 #5

"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
"tshad" <ts**********@f tsolutions.com> wrote:
I just got the VS today and will probably not get to it until next week,
but
I will try your examples. I need to get a handle on the whole code
behind
business.


Lucky you ! :)

I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared functions.

I am not starting a problem (I already have that set up without Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom
Nov 19 '05 #6
Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".

5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!

8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.

The Shared Function you created in the Global class is indeed global
to the application, that is, all pages and classes that it contains.
It is also static, which means that it is shared by all instances of
that application (which instantiates itself everytime a user logs onto
your site).

Be aware that, whereas Global.asax has two different views (Design and
Code), aspx pages have three (Graphical Design mode, HTML Design mode,
and Code).

If anything is still unclear, please ask.

Have fun!

Michel


"tshad" <ts**********@f tsolutions.com> wrote in message news:<OQ******* *******@TK2MSFT NGP14.phx.gbl>. ..
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
"tshad" <ts**********@f tsolutions.com> wrote:
I just got the VS today and will probably not get to it until next week,
but
I will try your examples. I need to get a handle on the whole code
behind
business.


Lucky you ! :)

I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared functions.

I am not starting a problem (I already have that set up without Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom

Nov 19 '05 #7
Hi Michel,

As you can see I am getting started with the VS and Classes. I will play
with your list this weekend to get it down. I actually have played with VS
for Visual Basic 6, so I have an idea how it works. I just haven't got down
to playing with it to get the ins and outs.

Thanks,

Tom

"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".

5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!

8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.

The Shared Function you created in the Global class is indeed global
to the application, that is, all pages and classes that it contains.
It is also static, which means that it is shared by all instances of
that application (which instantiates itself everytime a user logs onto
your site).

Be aware that, whereas Global.asax has two different views (Design and
Code), aspx pages have three (Graphical Design mode, HTML Design mode,
and Code).

If anything is still unclear, please ask.

Have fun!

Michel


"tshad" <ts**********@f tsolutions.com> wrote in message
news:<OQ******* *******@TK2MSFT NGP14.phx.gbl>. ..
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
> "tshad" <ts**********@f tsolutions.com> wrote:
>> I just got the VS today and will probably not get to it until next
>> week,
>> but
>> I will try your examples. I need to get a handle on the whole code
>> behind
>> business.
>
> Lucky you ! :)
>

I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared
functions.

I am not starting a problem (I already have that set up without
Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I
write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom

Nov 19 '05 #8
Hi Michel,

I just started doing your list. And had a question.

"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".
It won't let me put in a name, but will allow me to change the location, as
you mention and then the name changes. I assume this is how it is done.

5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!
Had my glass. Where do I send the bill :)

8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.

I tried that, but got an error:

"Error while trying to run object: Unable to start debugging on the web
server. Debugging failed because integrated Windows authentication is not
enabled. Click help for more information."

My other pages run, why not VS?

Thanks,

Tom The Shared Function you created in the Global class is indeed global
to the application, that is, all pages and classes that it contains.
It is also static, which means that it is shared by all instances of
that application (which instantiates itself everytime a user logs onto
your site).

Be aware that, whereas Global.asax has two different views (Design and
Code), aspx pages have three (Graphical Design mode, HTML Design mode,
and Code).

If anything is still unclear, please ask.

Have fun!

Michel


"tshad" <ts**********@f tsolutions.com> wrote in message
news:<OQ******* *******@TK2MSFT NGP14.phx.gbl>. ..
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
> "tshad" <ts**********@f tsolutions.com> wrote:
>> I just got the VS today and will probably not get to it until next
>> week,
>> but
>> I will try your examples. I need to get a handle on the whole code
>> behind
>> business.
>
> Lucky you ! :)
>

I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared
functions.

I am not starting a problem (I already have that set up without
Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I
write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom

Nov 19 '05 #9
Also, I can't find a "code" view in the View menu and can't find anything
that has an F7 shortcut on it.

I tried opening up one of my current pages and it show the code, but I can't
find a way to see how it looks in a design mode. There must be one (I would
assume), similar to the one you had me put the label on.

This is an aspx page. I wanted to see how the asp.net objects are rendered
inside VS.

Thanks,

Tom
"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Michel,

I just started doing your list. And had a question.

"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
Hi Tom!

Here is a somewhat standard procedure to achieve what you're looking
for.

As you will see, the "Visual" in "Visual Studio" will save you a lot
of time/hassles.

I will assume that you have never used any version of VS.

1) Launch VS. Create a Solution (File / New / New Solution). In the
Dialog that appears, just type a name, don't choose "Visual Basic
Projects" just yet. Let's call it TomSolution. Click OK.

2) Show the Solution Explorer window by choosing that option in the
View menu (I guess it's called View, my version isn't an english one,
third menu anyway).

3) Right-click on the Solution name in the Solution Explorer window,
and click "Add / Add new project".

4) In the dialog that appears, you can now choose "Visual Basic
Projects". Then choose "ASP.Net Web Application" in the icon list on
the right. Give it a name - TomApp - and click OK. In fact, you're not
giving a name, but the full path of the web app, in this case,
"http://localhost/TomApp".


It won't let me put in a name, but will allow me to change the location,
as you mention and then the name changes. I assume this is how it is
done.

5) After a few seconds, a default project is created. The Solution
Explorer shows a list of new items :
TomApp (the project)
References (a folder)
AssemblyInfo.vb
Global.asax
Styles.css
Web.config
WebForm1.aspx

6) Double-click on Global.asax. You get to the Design view of
Global.asax. This is a place where you're supposed to add components,
I guess, but I've never used it this way. Type F7 or choose "Code" in
the "View" menu.

7) That's it!!! This is where you wanted to be since the beginning. At
this point, have a glass of champagne, it's on me!!


Had my glass. Where do I send the bill :)

8) Add a new function below the existing subs:

Shared Function TextFeed()
Return "Hello global shared world"
End Function

9) Double-click on Webform1.aspx in the Solution Explorer. This takes
you to the design view of that page.

10) There is a toolbox tab somewhere (you'll get used to it very
quickly, but it can be a little unsettling at the beginning : tabs
everywhere, pinned to the left, docked to the right...). Click on it,
make sure the "Web Forms" subtab is selected, click on "Label" and
drag that to the page, anywhere. Just leave it's properties at their
default.

11) Type F7 or click on "Code" in the View menu.

12) A default stub is already in here. You have a Page_Load sub, which
is executed when the... page loads, yes. Inside this sub, just type :
Label1.Text = Global.TextFeed

13) Type F5 or choose "Run" in the Debug menu (could be "Start"
instead of "Run", not quite sure). This opens your default browser and
shows the Webform1.aspx page that you created. If everything went
well, it should show "Hello global shared world" somewhere in the
middle of it.


I tried that, but got an error:

"Error while trying to run object: Unable to start debugging on the web
server. Debugging failed because integrated Windows authentication is not
enabled. Click help for more information."

My other pages run, why not VS?

Thanks,

Tom
The Shared Function you created in the Global class is indeed global
to the application, that is, all pages and classes that it contains.
It is also static, which means that it is shared by all instances of
that application (which instantiates itself everytime a user logs onto
your site).

Be aware that, whereas Global.asax has two different views (Design and
Code), aspx pages have three (Graphical Design mode, HTML Design mode,
and Code).

If anything is still unclear, please ask.

Have fun!

Michel


"tshad" <ts**********@f tsolutions.com> wrote in message
news:<OQ******* *******@TK2MSFT NGP14.phx.gbl>. ..
"fd123456" <fd******@hotma il.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
> "tshad" <ts**********@f tsolutions.com> wrote:
>> I just got the VS today and will probably not get to it until next
>> week,
>> but
>> I will try your examples. I need to get a handle on the whole code
>> behind
>> business.
>
> Lucky you ! :)
>
I finally loaded my trial version of VS and need a little help getting
started with setting up the Global.asax.vb file to do my shared
functions.

I am not starting a problem (I already have that set up without
Code-behind
at the moment).

I just want to create the Global.asax.vb file. I am not sure what I
write
and what VS does for me.

Do I just start with a new Text file?

How do I tell it that this is the Global.asax file (other than saving it
that way)?

Where do I tell it to compile it?

I assume this will create my .dll that I move to my bin folder.

Thanks,

Tom


Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15872
by: Tom Bates | last post by:
Possible? It seems nobody knows how... :-) Tom
1
280
by: fd123456 | last post by:
Hi tshad, sorry for not coming back to you earlier. When I meant to add a method to Global.asax, I actually meant to add it to the code-behind file. If you click on "Global.asax" in the file explorer, then on the F7 key, you can edit this code-behind; that's the one that includes the Application_Start, Application_BeginRequest, etc, routines (I don't even know where you added the <script> bit). In this file, you can add your own...
1
2240
by: | last post by:
Hi all, Is it possible to have custom function/subroutines in global.asax? e.g. DoMyWork(i as integer) etc etc. If yes, how can I access this code in my ..aspx pages? I know I can put this into a seperate dll in the bin directory, but to keep it simple global.asax would be nice too.. TIA!
7
3004
by: Microsoft | last post by:
I'm not sure where to physically place my subroutines in vb.net I get namespace and not declared errors... Imports System Imports System.Management Public Class Form1
2
1891
by: Christoph Haas | last post by:
Evening, I'm currently working on a larger Python project that consists of multiple programs and packages. As I need a few utility functions time and again I moved them all into a Utility package and created a class there. Like this: Util.py: ~~~~~~~~ class Util: def __init__(self, debugFlag=False, vibranceLevel='good'):
1
2262
by: u0107 | last post by:
Hello, I am developing a website with an MS-Access backend database. One of the tables in the database is tblUser. On accessing my website, a user is required to provide a valid user id and a password. Once a user id and password is provided, it is validated against appropriate fields in tblUser and a "logged in" flag (another field in tblUser) is set to "True". I want to set the flag to "False" at the end of the session. Session...
11
3164
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global" storage is ButtonHasBeenClicked. In this simple example code in Form1 calls a routine in Module1 which then calls code back in Form1 (subroutine WhatEver). WhatEver needs to access ButtonHasBeenClicked but the reference to ButtonHasBeenClicked...
2
2358
by: David Morgan | last post by:
Hi Guys I have been working with ASP for many years but have _never_ come across this. Sure, I've had the global.asa not execute because of application misconfiguration, but check this out... Server (W2K3 R2) reboots, website comes back up, but no application variables loaded. What makes it even more bizarre is that the variables that are set in
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.