global function in asp net

  • Thread starter Thread starter ray well
  • Start date Start date
R

ray well

hi,

i have a function i need to use in various aspx pages and would like to keep
it in one place instead of duplicating it in every page i want to use it.

i tried puting it in 'Global.asax' declaring it as public, thinking it would
have a global scope, but when i called the function in a aspx page it is not
recognized.

i couldn't find a way to add a module to the project in which to put it
either.

i there a way to have a function with global scope in asp net? would
appreciate a bit of code.

thanks

ray
 
You create a "utility" class with static/shared memebers:

public class Utility
public shared function ConvertString(byval value as string) as string
return 'do smoethin
end function
end class

and can then access it via Utility.ConvertString("yy")

Karl
 
Put it in a class library and add a reference from the aspx project to the
class library project.

Eliyahu
 
Back
Top