473,320 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

global function in asp net

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
Nov 19 '05 #1
2 3860
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
"ray well" <no****@nospam.com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #2
Put it in a class library and add a reference from the aspx project to the
class library project.

Eliyahu

"ray well" <no****@nospam.com> wrote in message
news:OP*************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
8
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
1
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
16
by: Roman Ziak | last post by:
Hello, there were times when I used to be looking for a way to access JavaScript Global object similar to those found in VBScript or PHP ($GLOBALS). At present this has only academic value for...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
9
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.