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 KumarArchitectCommented:
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
 
Obadiah ChristopherCommented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Obadiah ChristopherCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.