global function in asp net

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
 
K

Karl Seguin

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
 
E

Eliyahu Goldin

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

Eliyahu
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top