Global subroutines

F

fd123456

Hi Tom,

I have just read your previous message about not having VS. I have
never tried compiling anything without it, so I don't know the
particular pitfalls you might encounter.

Global.asax is not a code-behind file. In VS, there is another file,
called Global.asax.vb, which contains (comments removed) :

Imports System.Web
Imports System.Web.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

(then the standard Application_Start, etc, stuff)

End Class

Apparently, you're using <script> tags in your Global.asax, which
sounds strange, because it's not a web page at all. There is a
"design" mode in VS, but no web page associated to it.

Inside this class, I added :

Shared Function test() As String
Return "hello"
End Function

And in a WebForm, I added a Label and edited the Page_Load handler
thus :

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Global.test
End Sub

When running the project, the label does show "hello". This might help
: in my Webform.aspx, the header differs from yours. It's :

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="myTestProject.WebForm1"%>

...where "myTestProject" is the name of - you guessed it - my project,
and "WebForm1" is the name of my WebForm.

To sum up, I think that your Global.asax file needs to contains an
explicit "Global" class.

That being said, although I command your courage to start a web app
without VS, I would strongly advise you to download, if at all
possible, a demo version of it (I know there's a 90-day fully
functional demo somewhere, and think I've seen something like "2005
express"), so you can at last test the system the easy way and then
analyse how VS builds its codebehind files and key project files.

Keep me posted if you're still in trouble.

Michel.
 
T

tshad

fd123456 said:
Hi Tom,

I have just read your previous message about not having VS. I have
never tried compiling anything without it, so I don't know the
particular pitfalls you might encounter.

Global.asax is not a code-behind file. In VS, there is another file,
called Global.asax.vb, which contains (comments removed) :

Right.

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.
Imports System.Web
Imports System.Web.SessionState

Public Class Global
Inherits System.Web.HttpApplication

Public Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private components As System.ComponentModel.IContainer

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

(then the standard Application_Start, etc, stuff)

End Class

Apparently, you're using <script> tags in your Global.asax, which
sounds strange, because it's not a web page at all. There is a
"design" mode in VS, but no web page associated to it.

Inside this class, I added :

Shared Function test() As String
Return "hello"
End Function

And in a WebForm, I added a Label and edited the Page_Load handler
thus :

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Global.test
End Sub

When running the project, the label does show "hello". This might help
: in my Webform.aspx, the header differs from yours. It's :

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="myTestProject.WebForm1"%>

..where "myTestProject" is the name of - you guessed it - my project,
and "WebForm1" is the name of my WebForm.

To sum up, I think that your Global.asax file needs to contains an
explicit "Global" class.

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.

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).
That being said, although I command your courage to start a web app
without VS, I would strongly advise you to download, if at all
possible, a demo version of it (I know there's a 90-day fully
functional demo somewhere, and think I've seen something like "2005
express"), so you can at last test the system the easy way and then
analyse how VS builds its codebehind files and key project files.

I did that last night, as you suggested, and just have to wait for the CD.

Thanks,

Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top