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.
2. Now right click on this newly created folder and again click Add New Item. From the list of all items choose Class file.
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:
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:
Well! This is it.
Enjoy. Happy Coding.