473,322 Members | 1,232 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,322 software developers and data experts.

global functions?

hi all

just a quick one, where can i put functions that all asp.net pages
within an application can call? i tried globla.asax.vb, but that did
not work.

TIA!!!

Chris
Jan 13 '06 #1
8 1114
Go for a base page(a simple aspx page), which holds the common
functions
namespace yournamespace

public class yourclass :basepage // instead of yourclass :
System.Web.UI.Page
{
}

while loading the page it will load the common function from the base
page.

Jan 13 '06 #2
On 13 Jan 2006 01:50:15 -0800, "MSEN" <ma******@gmail.com> wrote:
i am sorry, i do not follow, could you pack that into a very small
example of what to put in what file, or point me to a link?

thanks a lot!!

regards,
Chris
Go for a base page(a simple aspx page), which holds the common
functions
namespace yournamespace

public class yourclass :basepage // instead of yourclass :
System.Web.UI.Page
{
}

while loading the page it will load the common function from the base
page.


Jan 13 '06 #3
Dan
Personally i make functions for any global activity in a separate project
and then compile to make the dll. Then add the resulting DLL as a reference
in your projects that you want to use them.

that way you can build up a complete class library that is separate from the
sub projects that use it without the need for a global aspx page holding
them all.

--
Dan
"Chattanooga" <ro***@gmx.at> wrote in message
news:et********************************@4ax.com...
hi all

just a quick one, where can i put functions that all asp.net pages
within an application can call? i tried globla.asax.vb, but that did
not work.

TIA!!!

Chris

Jan 13 '06 #4
If you use ASP.NET 2.0 you can add an app_code folder and add a class
to this folder

HTH

-----------------------------------------
David Gray
ASP.NET/C# Developer/Architect (MCAD.NET)

On Fri, 13 Jan 2006 09:36:00 GMT, Chattanooga <ro***@gmx.at> wrote:
hi all

just a quick one, where can i put functions that all asp.net pages
within an application can call? i tried globla.asax.vb, but that did
not work.

TIA!!!

Chris

Jan 13 '06 #5
On Fri, 13 Jan 2006 10:52:43 -0000, "Dan" <dv*******@aol.com> wrote:
Personally i make functions for any global activity in a separate project
and then compile to make the dll. Then add the resulting DLL as a reference
in your projects that you want to use them.

that way you can build up a complete class library that is separate from the
sub projects that use it without the need for a global aspx page holding
them all.


hi,

thanks for the hint, is there a link that describes this process in
any detail?

tia,
Christian
Jan 13 '06 #6
It's not shown in the dialog but you can create modules as in VB6.
Simply add a class module, rename CLASS for Module (+ end module : ) )
Each function in the module is now public.

O well, this might be slightly different in c though.


"Chattanooga" <ro***@gmx.at> schreef in bericht
news:et********************************@4ax.com...
hi all

just a quick one, where can i put functions that all asp.net pages
within an application can call? i tried globla.asax.vb, but that did
not work.

TIA!!!

Chris

Jan 13 '06 #7
I think the other responses are tyring to make things more complex. Many
refer to the physical location such as another DLL or the app_code folder.

Really, just make another class and create static methods.

public class Utilities{
public static MethOne(){
}

public static MethTwo(){
}
}

Then you can call the methods from anywhere by invoking Utilities.MethOne()
and so on.
"Chattanooga" <ro***@gmx.at> wrote in message
news:et********************************@4ax.com...
hi all

just a quick one, where can i put functions that all asp.net pages
within an application can call? i tried globla.asax.vb, but that did
not work.

TIA!!!

Chris

Jan 13 '06 #8
Dan
Sorry dont know any but it is really simple.

Basically, start a new web app as you would normally.

Code your classes that you want everything to have access to, set to release
mode and compile.

The bin directory will hold a dll file. That dll file is the compiled
dynamic link library of those classes.

Now to include that dll go to your main project and on the right pane it
says references.

Right clik on that and i think it says add reference or something similar.
Choose this.

Now in the subsequent window browse for the dll and select it, say ok and
voila it has been added as a reference (i believe it also copies the dll
into your bin app of your current application for you as well but dont quote
me on that)

Now say your dll had a class in it in a namespace called yourNamespace and a
class called MyClass. You simply add this at the top of your page:

using yourNamespace;

and in your code you can put:

MyClass _myObj = new MyClass();

And access it as usual.

Hope that is all clear, i wrote this from memory so i hope i havent missed
any steps, failry self explanatory. Very neat way of adding global code and
in my opinion the way to do it.
--
Dan
"Chattanooga" <ro***@gmx.at> wrote in message
news:pe********************************@4ax.com...
On Fri, 13 Jan 2006 10:52:43 -0000, "Dan" <dv*******@aol.com> wrote:
Personally i make functions for any global activity in a separate project
and then compile to make the dll. Then add the resulting DLL as a
reference
in your projects that you want to use them.

that way you can build up a complete class library that is separate from
the
sub projects that use it without the need for a global aspx page holding
them all.


hi,

thanks for the hint, is there a link that describes this process in
any detail?

tia,
Christian

Jan 13 '06 #9

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...
11
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
7
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
10
by: ankisharma | last post by:
Hi all At many places I have seen that programmers pass global variables to functions in c. I am not able to figure out why they do so. need some clues on this. somewhere i heard that this...
10
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
7
by: zeecanvas | last post by:
Hi, First of all: Yes, I know global variables are bad, but I've a huge amount of legacy code, and I've to maintain it _as_is_. I'm maintaining a big program. I moved all (program-wide scope)...
10
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.