Public functions and variables

Discussion in 'ASP .Net' started by John, Feb 11, 2007.

  1. John

    John Guest


    Is there a way to declare public functions that can be accessed in any aspx
    page? Can global variables be declared?


    John, Feb 11, 2007
    1. Advertisements

  2. Read up on "Singleton"...
    You'd probably find a zillion implementations at google if you combine
    your search with C# or something...!!

    Thomas Hansen, Feb 11, 2007
    1. Advertisements

  3. John

    Matt Vaughn Guest

    Within the code-behind of the .aspx page, you can create public methods and
    properties. The page should have access to them: <#% GetCurrentTime() %>
    will work if you have a public method like:

    public DateTime GetCurrentTime()
    //add code here to return DateTime value;
    Matt Vaughn, Feb 11, 2007
  4. John

    Guest Guest

    Guest, Feb 11, 2007
  5. John

    John Guest

    Thanks for that. I have created the function in Global.asax file in the
    site root as follows;

    script language="VB" runat="Server">
    Shared Function MyFunction(ByVal d As Object, ByVal pat As Object) As Object

    End Function

    However when I use it in one of my pages as below;

    MyVar = Global.MyFunction(Now, "dd/mm/yyyy hh:mm:ss")

    I get an '"MyFunction is not a member of '<default>' error. What am I doing


    John, Feb 11, 2007
  6. John

    Guest Guest

    Global.ASP.global_asax.MyFunction(Now, "dd/mm/yyyy hh:mm:ss")
    Guest, Feb 12, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.