Re: Global subroutines

From: tshad (tscheiderich_at_ftsolutions.com)
Date: 02/04/05


Date: Fri, 4 Feb 2005 15:11:44 -0800


"fd123456" <fd123456@hotmail.com> wrote in message
news:c8d02ef8.0502041004.26f2adca@posting.google.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="Global.asax.cs"
> Inherits="myNamespace.Global" %>
>
> When I open an aspx page, I get this:
>
> <%@ Page language="c#" Codebehind="myPage.aspx.cs"
> AutoEventWireup="false" Inherits="myNamespace.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 "Application" 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.dll": 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.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
>
> Public Test() as String
> Return "hello";
> End Sub
> End Class
>
> Create one "TestPage.aspx" containing :
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="TestPage.aspx.vb" Inherits="myNamespace.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.Page
> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) 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



Relevant Pages

  • Re: overloads - why this code compile??? Please MS answer...
    ... Why wouldn't it compile? ... In your specific sample I see Overloads as largely synonymous with Shadows, ... > the sub as exactly the same parameters.... ... > Public Class Derived ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Late Binding .....
    ... Public Class TestClass ... Public Sub HelloWorld() ... Compile this code and create Test.Dll ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Question on - Automatic compilation of VB.NET files on a Web Server
    ... Is there a way to make this work without having to compile MySecurity.vb ... Public Sub New ... Namespace Sandbox.BLL ... Public Class MySecurity ...
    (microsoft.public.dotnet.framework)
  • Re: Question on - Automatic compilation of VB.NET files on a Web Server
    ... > Public Sub New ... > Public Class MySecurity ... > Public Function AuthenticateAs String ... >> have ASP.NET compile it. ...
    (microsoft.public.dotnet.framework)
  • Re: Global subroutines
    ... >> surround the code with the script tags. ... > HTML code for Global.asax (usually, an aspx combo has three different ... and the code-behind file which sits in another window. ... > You definitely need to compile the file in any case. ...
    (microsoft.public.dotnet.framework.aspnet)

Loading