Solved

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

Posted on 2011-02-14
7
496 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now