954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C# Function Library

Hi all,

I am quite a beginner to C# and ASP.NET development so if you can help out it would be really appreciated:

I wish to build a small library of custom functions to be used throughout the entire website. For example say I need to build 5 functions which are used all the time from multiple pages of the website.

When I used to use Classic ASP (VB) I would have done them in a file and then #include that file and the functions would become available. Can this be done in .NET using C# and if so can you provde a small example of a function and how to invoke it.

Thank you and apologies if anyone answered this already in some other thread.

Thanks
Darren

dmizz002
Newbie Poster
4 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

Create a directory called App_code. Create a Class. Add all your functions in that class as shared/static members(so you need not to create Instance every time). You can then use it in any page directly by typing ClassName.MemberName

hope this helps you.
Vinod DAnekar

vsoftline
Newbie Poster
1 post since May 2011
Reputation Points: 10
Solved Threads: 0
 

Thanks Vinod!! The static / shared actually solved it because my worry was that I had to create an instance of the class every time I needed to use the functions.

Regards
Darren

dmizz002
Newbie Poster
4 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

Hi

Create a new class form and put App_code directory .
Write valid function and use as a global function any where in form

A. nandey

nandey
Newbie Poster
3 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

APP_Code is used for class libraries functions

aspproject
Junior Poster in Training
Banned
78 posts since Apr 2011
Reputation Points: 1
Solved Threads: 3
Infraction Points: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: