How to call code in aspx webform from functions defined in code behind modules

Discussion in 'ASP .Net' started by CW, May 2, 2004.

  1. CW

    CW Guest

    I find it necessary to mix code-behind and non-code behind techniques
    sometimes.

    I have utility functions defined in a VB module. Is there anyway for me to
    call functions defined in VB module from aspx form (i.e., code mixed in with
    html elements) or even call public shared functions from other code behind
    classes)?
     
    CW, May 2, 2004
    #1
    1. Advertising

  2. CW

    Rick Spiewak Guest

    <%=FunctionName%> in the HTML will call your code-behind function, which
    must be defined as Protected.

    "CW" <a> wrote in message news:...
    > I find it necessary to mix code-behind and non-code behind techniques
    > sometimes.
    >
    > I have utility functions defined in a VB module. Is there anyway for me to
    > call functions defined in VB module from aspx form (i.e., code mixed in

    with
    > html elements) or even call public shared functions from other code behind
    > classes)?
    >
    >
     
    Rick Spiewak, May 2, 2004
    #2
    1. Advertising

  3. CW

    CW Guest

    Thanks for the help

    "Rick Spiewak" <> wrote in message
    news:...
    > <%=FunctionName%> in the HTML will call your code-behind function, which
    > must be defined as Protected.
    >
    > "CW" <a> wrote in message news:...
    > > I find it necessary to mix code-behind and non-code behind techniques
    > > sometimes.
    > >
    > > I have utility functions defined in a VB module. Is there anyway for me

    to
    > > call functions defined in VB module from aspx form (i.e., code mixed in

    > with
    > > html elements) or even call public shared functions from other code

    behind
    > > classes)?
    > >
    > >

    >
    >
     
    CW, May 2, 2004
    #3
  4. CW

    John Sivilla Guest

    You can access code from code modules, however you must declare the
    Module Public and you must qualify the call with the proper namespace.
    For example:

    in you module:

    Public Module Module1
    Public Function getString() As String
    Return "from module"
    End Function
    End Module

    in your call:

    <%=VBTest.Module1.getString()%>

    where VBTest is the name of the project or parent namespace of
    Module1.

    hope this helps,

    John
     
    John Sivilla, May 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paolo Pignatelli
    Replies:
    6
    Views:
    2,197
    Paolo Pignatelli
    Feb 21, 2005
  2. =?Utf-8?B?YW5vb3A=?=
    Replies:
    0
    Views:
    462
    =?Utf-8?B?YW5vb3A=?=
    Jun 17, 2005
  3. Tian
    Replies:
    2
    Views:
    391
    Reinhold Birkenfeld
    Mar 20, 2005
  4. Oodini
    Replies:
    1
    Views:
    1,779
    Keith Thompson
    Sep 27, 2005
  5. Alok
    Replies:
    3
    Views:
    257
Loading...

Share This Page