How to create global Funtions & Routines

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default How to create global Funtions & Routines

    I'm at a loss on how to create global functions for my website.
    Essentially, I have several different functions I use throughout my site and
    I want to be able to put these in 1 file and call them from anywhere.
    Currently, I just copy them into each aspx file... Not what I want to do.

    Any help? BTW, I am using WebMatrix to develope the aspx forms.
    TIA
    -Matt


    Matthew Hood Guest

  2. Similar Questions and Discussions

    1. Want to create a stand-alone CD of Flash that does not require users to adjust global security settings panel (always allow)
      I am trying to put a swf file on to a CD to standalone offline. The swf file points to html files that are included on the CD. When I click on...
    2. Calling on Visual Basic funtions
      How can I call a funtion on Visual Basic from the event "Onblur" of a Textbox,,, in a webpage?
    3. OCR funtions in Acrobat 7 SDK
      Hi I have a rather simple question - can I programmatically (from VB for example) use the Acrobat 7 SDK API functions to control/operate the OCR...
    4. Wizards to create table maintainance routines?
      I've been using CF for many years and have created numerous applications to allow users to add, update and delete records from SQL tables. However,...
    5. IBM AIX 5.1 routines
      i need help finding out what these two aix routines are/do: local_lock_ppc_mp local_unlock_ppc_mp Does anyone have any info on where I can found...
  3. #2

    Default Re: How to create global Funtions & Routines

    Welcome to object oriented programming. ;o)

    Each page in your site is a class. You'll note at the top of your
    codebehind file (I'm assuming you have this in webmatrix?) that you specifiy
    a class name for your page... e.g. "Public Class myPage"... this "page" is a
    public class, so it is available to any part of your application. (Assuming
    it exposes the methods you need).

    Lets assume you have a function in your codebehind file that you want to
    access elsewhere in your web application. You can just create an instance
    of the other "page" (class) from within your current codebehind file by
    just stating:

    dim myTool as new myPage()

    where myPage is the class that contains the method you wish to use. For
    example if you had a function that added two numbers in your myPage class
    called "addIt" you could say:

    dim myTool as new myPage()
    dim myresult as Integer = myTool.addIt(number1, number2)

    What you really need to do is have a class library. (just a file with a .vb
    extension) in you application with the classes you wish to implement
    globally, that way when you create an instance of the "tool" you need you
    aren't using all the extra memory neccessary to create an instance of the
    myPage class. (because it inherits from the Page class which has a ton of
    methods, etc..)

    Hope that helps.

    -MC D


    "Matthew Hood" <mshood@qwest.net> wrote in message
    news:uoU6kcpODHA.3020@TK2MSFTNGP10.phx.gbl...
    > I'm at a loss on how to create global functions for my website.
    > Essentially, I have several different functions I use throughout my site
    and
    > I want to be able to put these in 1 file and call them from anywhere.
    > Currently, I just copy them into each aspx file... Not what I want to do.
    >
    > Any help? BTW, I am using WebMatrix to develope the aspx forms.
    > TIA
    > -Matt
    >
    >

    MC D Guest

  4. #3

    Default Re: How to create global Funtions & Routines

    Webmatrix does not use the Codebehind method.
    Initially I created the functions in a .vb file, but when I tried to access
    them from a page, I get an error stating that the routines were not defined.
    Do the vb files have to be compiled?

    TIA-
    Matt

    "MC D" <nospam@earthtalk.com> wrote in message
    news:vfi9po4kc9np5c@corp.supernews.com...
    > Welcome to object oriented programming. ;o)
    >
    > Each page in your site is a class. You'll note at the top of your
    > codebehind file (I'm assuming you have this in webmatrix?) that you
    specifiy
    > a class name for your page... e.g. "Public Class myPage"... this "page" is
    a
    > public class, so it is available to any part of your application.
    (Assuming
    > it exposes the methods you need).
    >
    > Lets assume you have a function in your codebehind file that you want to
    > access elsewhere in your web application. You can just create an instance
    > of the other "page" (class) from within your current codebehind file by
    > just stating:
    >
    > dim myTool as new myPage()
    >
    > where myPage is the class that contains the method you wish to use. For
    > example if you had a function that added two numbers in your myPage class
    > called "addIt" you could say:
    >
    > dim myTool as new myPage()
    > dim myresult as Integer = myTool.addIt(number1, number2)
    >
    > What you really need to do is have a class library. (just a file with a
    ..vb
    > extension) in you application with the classes you wish to implement
    > globally, that way when you create an instance of the "tool" you need you
    > aren't using all the extra memory neccessary to create an instance of the
    > myPage class. (because it inherits from the Page class which has a ton of
    > methods, etc..)
    >
    > Hope that helps.
    >
    > -MC D
    >
    >
    > "Matthew Hood" <mshood@qwest.net> wrote in message
    > news:uoU6kcpODHA.3020@TK2MSFTNGP10.phx.gbl...
    > > I'm at a loss on how to create global functions for my website.
    > > Essentially, I have several different functions I use throughout my site
    > and
    > > I want to be able to put these in 1 file and call them from anywhere.
    > > Currently, I just copy them into each aspx file... Not what I want to
    do.
    > >
    > > Any help? BTW, I am using WebMatrix to develope the aspx forms.
    > > TIA
    > > -Matt
    > >
    > >
    >
    >

    Matthew Hood Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139