re-use function

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Hello,

I want to us a function on some different pages. How do I have to do
that.

For example, te function is
function test(strText as string)
response.write(strText)
end function

On page 1 I want to display: "thanks for your help" bij issueing the
command
test("thanks for your help")

On page 2 I display "thanks again" bij calling test("thanks again")

I thought I could save the function in a .ascx file and register it
with <%@ Register TagPrefix="jb" TagName="test" src="/test.ascx" %>

but this does not work, you can use usercontrols this way but I cannot
call the function.

John
 
The best way is to use a class file with a static function:

utility.vb

public class Utility
public shared sub Test(strText as string)
HttpContext.Current.Response.Write(strText)
end sub
end class

which you can then use via:
Utility.Test("blah")


Karl
 
Back
Top