Solved

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

Posted on 2011-02-14
7
500 Views
Last Modified: 2012-05-11
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!
0
Comment
Question by:mawingho
7 Comments
 
LVL 12

Accepted Solution

by:
Mamtha1982 earned 167 total points
ID: 34894251
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
 

Author Comment

by:mawingho
ID: 34894253
i tried to do that...
and i wanna set the session variable
but it does not allow me to do that...
0
 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 333 total points
ID: 34894256
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 333 total points
ID: 34894280
U need to add a reference of System.Web & use HttpContext.Current.Session["myVar"]=val;
0
 

Author Comment

by:mawingho
ID: 34894282
hot it thanks
0
 

Author Closing Comment

by:mawingho
ID: 34894283
thanks
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 34894287
add

Imports System.Web.UI.Page

will allow you to use sesions in the page
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC - Views 3 40
Json and ajax 1 20
Header Font Size in Grid View 6 25
ASP.NET Complete Life Cycle for all the controls 2 20
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question