ASP.NET C# Create a class / function that can be used among all pages

How to create a class / function that can be used among all pages?

should I create a class page and add my function there?

Thank you!
mawinghoAsked:
Who is Participating?
 
Praveen KumarConnect With a Mentor ArchitectCommented:
Yes you can do...

Add New Item -> Class

Than add you functions as "public". if you want call this function without creating object, make it as "static"

0
 
mawinghoAuthor Commented:
i tried to do that...
and i wanna set the session variable
but it does not allow me to do that...
0
 
informaniacConnect With a Mentor Commented:
The class has 2 b static. Or u can create a class tht inherits frm Page class & have all ur .cs files inherit frm this
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
informaniacConnect With a Mentor Commented:
U need to add a reference of System.Web & use HttpContext.Current.Session["myVar"]=val;
0
 
mawinghoAuthor Commented:
hot it thanks
0
 
mawinghoAuthor Commented:
thanks
0
 
Pratima PharandeCommented:
add

Imports System.Web.UI.Page

will allow you to use sesions in the page
0
All Courses

From novice to tech pro — start learning today.