You are here: Home » Questions & Answers » How to / Code / Applications » How to create Global functions in Asp.Net 4.0 ?

How to create Global functions in Asp.Net 4.0 ?

There are many ways to create a global functions in Asp.Net.

You can either use a class.cs file or you can use a global.asax file or you can use a http handler.

In this tut, today i will explain you how to create a global function using a class.cs file.

1. First, go to your Solution Explorer. Then right click onto the top navigation and click Add ASP.NET Folder and then App_Code.

create global functions in asp.net

 

2. Now right click on this newly created folder and again click Add New Item. From the list of all items choose Class file.

create global functions in asp.net

 

After adding a class file inside the App_Code foledr, you will be presented with a pre generatd classes inside.
This is your class where you are going to work. While some of the things are pre-written, you still needs to add a bit of codes like this:

create global functions in asp.net

Sometimes the same class name inside another class might return an error, so change the class name if it does.
Now you can call this class in any section of your application as you want. To call this class, use:

Class1.classnew();

Well! This is it.

Enjoy. Happy Coding.

About Ansh

Ansh is Webloggerz.com's Founder & Editor. His interests include WordPress Theme Development, Blogging & Traveling. You can be friend with him on:

2 comments

  1. Elizabet Kalenak

    Wow!, this was a top quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate a lot and never seem to get something done.

    • Levi Johansen

      Thanks for the information, I really care.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge
Scroll To Top