Groups | Blog | Home
all groups > asp.net > march 2005 >

asp.net : re-use function


Karl Seguin
3/23/2005 6:05:18 PM
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

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


[quoted text, click to view]

JB
3/23/2005 11:00:53 PM
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.

AddThis Social Bookmark Button