Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-14
7
Medium Priority
?
503 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:
Praveen Kumar earned 668 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 1332 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 1332 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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