Global Routines

Results 1 to 2 of 2

Thread: Global Routines

  1. #1
    Join Date
    Dec 1969

    Default Global Routines

    I’m learning web programming thru books – no classes, no instruction. And I really don’t have anybody to ask questions – except you all. You’ve been great, & I thank you for being patient with my elementary questions. The books I’m using are: “Teach Yourself ASP.Net in 24 Hours” by Scott Mitchell, “ASP.Net Unleashed” by Stephen Walther, “Visual Basic.Net Programmer’s Reference” by Dan Rahmel, as well as HTML & SQL reference books. It’s actually going pretty well, but I’m having trouble understanding exactly how to make routines global. I have several subroutines & functions that need to be available to a number of pages. I’ve tried Global.asax, but couldn’t get it to work. Is this what I should be using, or is there another way? Is there some special code that needs to be used? It isn't explained very clearly in "ASP.Net Unleashed", which is the only one of my books that goes into it at all. Could you suggest a book that would be more helpful to me, or could you explain exactly what I need to do? I really think an example would help.

  2. #2
    Join Date
    Dec 1969

    Default what you need is a "module"

    like "MyFunctions.vb" (or "MyFunctions.cs")<BR><BR>Code:<BR>[code language="VB.NET"]Module MyFunctions<BR> Public Function GetUsername() As String<BR> .....<BR> .....<BR> End function<BR><BR> Public Sub DoSomething()<BR> .....<BR> .....<BR> End Sub<BR>End Module[/code]<BR><BR>once you compile, you can simply say<BR><BR>[code language="VB.NET"]Dim MyUsername As String = GetUsername()[/code]<BR><BR>anywhere you want in the project

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts