global functions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chattanooga

    #1

    global functions?

    hi all

    just a quick one, where can i put functions that all asp.net pages
    within an application can call? i tried globla.asax.vb, but that did
    not work.

    TIA!!!

    Chris
  • MSEN

    #2
    Re: global functions?

    Go for a base page(a simple aspx page), which holds the common
    functions
    namespace yournamespace

    public class yourclass :basepage // instead of yourclass :
    System.Web.UI.P age
    {


    }

    while loading the page it will load the common function from the base
    page.

    Comment

    • Chattanooga

      #3
      Re: global functions?

      On 13 Jan 2006 01:50:15 -0800, "MSEN" <mailmsen@gmail .com> wrote:


      i am sorry, i do not follow, could you pack that into a very small
      example of what to put in what file, or point me to a link?

      thanks a lot!!

      regards,
      Chris
      [color=blue]
      >Go for a base page(a simple aspx page), which holds the common
      >functions
      >namespace yournamespace
      >
      >public class yourclass :basepage // instead of yourclass :
      >System.Web.UI. Page
      >{
      >
      >
      >}
      >
      >while loading the page it will load the common function from the base
      >page.[/color]

      Comment

      • Dan

        #4
        Re: global functions?

        Personally i make functions for any global activity in a separate project
        and then compile to make the dll. Then add the resulting DLL as a reference
        in your projects that you want to use them.

        that way you can build up a complete class library that is separate from the
        sub projects that use it without the need for a global aspx page holding
        them all.

        --
        Dan
        "Chattanoog a" <rowan@gmx.at > wrote in message
        news:etses1tbun bj121c7crffh1q2 3b9ponm5b@4ax.c om...[color=blue]
        > hi all
        >
        > just a quick one, where can i put functions that all asp.net pages
        > within an application can call? i tried globla.asax.vb, but that did
        > not work.
        >
        > TIA!!!
        >
        > Chris[/color]


        Comment

        • DavidG

          #5
          Re: global functions?

          If you use ASP.NET 2.0 you can add an app_code folder and add a class
          to this folder

          HTH

          -----------------------------------------
          David Gray
          ASP.NET/C# Developer/Architect (MCAD.NET)

          On Fri, 13 Jan 2006 09:36:00 GMT, Chattanooga <rowan@gmx.at > wrote:
          [color=blue]
          >hi all
          >
          >just a quick one, where can i put functions that all asp.net pages
          >within an application can call? i tried globla.asax.vb, but that did
          >not work.
          >
          >TIA!!!
          >
          >Chris[/color]

          Comment

          • Chattanooga

            #6
            Re: global functions?

            On Fri, 13 Jan 2006 10:52:43 -0000, "Dan" <dvazanias@aol. com> wrote:
            [color=blue]
            >Personally i make functions for any global activity in a separate project
            >and then compile to make the dll. Then add the resulting DLL as a reference
            >in your projects that you want to use them.
            >
            >that way you can build up a complete class library that is separate from the
            >sub projects that use it without the need for a global aspx page holding
            >them all.[/color]

            hi,

            thanks for the hint, is there a link that describes this process in
            any detail?

            tia,
            Christian

            Comment

            • Edwin Knoppert

              #7
              Re: global functions?

              It's not shown in the dialog but you can create modules as in VB6.
              Simply add a class module, rename CLASS for Module (+ end module : ) )
              Each function in the module is now public.

              O well, this might be slightly different in c though.




              "Chattanoog a" <rowan@gmx.at > schreef in bericht
              news:etses1tbun bj121c7crffh1q2 3b9ponm5b@4ax.c om...[color=blue]
              > hi all
              >
              > just a quick one, where can i put functions that all asp.net pages
              > within an application can call? i tried globla.asax.vb, but that did
              > not work.
              >
              > TIA!!!
              >
              > Chris[/color]


              Comment

              • Peter Rilling

                #8
                Re: global functions?

                I think the other responses are tyring to make things more complex. Many
                refer to the physical location such as another DLL or the app_code folder.

                Really, just make another class and create static methods.

                public class Utilities{
                public static MethOne(){
                }

                public static MethTwo(){
                }
                }

                Then you can call the methods from anywhere by invoking Utilities.MethO ne()
                and so on.


                "Chattanoog a" <rowan@gmx.at > wrote in message
                news:etses1tbun bj121c7crffh1q2 3b9ponm5b@4ax.c om...[color=blue]
                > hi all
                >
                > just a quick one, where can i put functions that all asp.net pages
                > within an application can call? i tried globla.asax.vb, but that did
                > not work.
                >
                > TIA!!!
                >
                > Chris[/color]


                Comment

                • Dan

                  #9
                  Re: global functions?

                  Sorry dont know any but it is really simple.

                  Basically, start a new web app as you would normally.

                  Code your classes that you want everything to have access to, set to release
                  mode and compile.

                  The bin directory will hold a dll file. That dll file is the compiled
                  dynamic link library of those classes.

                  Now to include that dll go to your main project and on the right pane it
                  says references.

                  Right clik on that and i think it says add reference or something similar.
                  Choose this.

                  Now in the subsequent window browse for the dll and select it, say ok and
                  voila it has been added as a reference (i believe it also copies the dll
                  into your bin app of your current application for you as well but dont quote
                  me on that)

                  Now say your dll had a class in it in a namespace called yourNamespace and a
                  class called MyClass. You simply add this at the top of your page:

                  using yourNamespace;

                  and in your code you can put:

                  MyClass _myObj = new MyClass();

                  And access it as usual.

                  Hope that is all clear, i wrote this from memory so i hope i havent missed
                  any steps, failry self explanatory. Very neat way of adding global code and
                  in my opinion the way to do it.


                  --
                  Dan
                  "Chattanoog a" <rowan@gmx.at > wrote in message
                  news:pe4fs11fta m2nu3ne2hh1eh30 ekjf45s1l@4ax.c om...[color=blue]
                  > On Fri, 13 Jan 2006 10:52:43 -0000, "Dan" <dvazanias@aol. com> wrote:
                  >[color=green]
                  >>Personally i make functions for any global activity in a separate project
                  >>and then compile to make the dll. Then add the resulting DLL as a
                  >>reference
                  >>in your projects that you want to use them.
                  >>
                  >>that way you can build up a complete class library that is separate from
                  >>the
                  >>sub projects that use it without the need for a global aspx page holding
                  >>them all.[/color]
                  >
                  > hi,
                  >
                  > thanks for the hint, is there a link that describes this process in
                  > any detail?
                  >
                  > tia,
                  > Christian[/color]


                  Comment

                  Working...