Click here to Skip to main content
15,892,537 members
Home / Discussions / C#
   

C#

 
AnswerRe: Please can someone do me a favour and run a C# test for me Pin
PIEBALDconsult13-Feb-11 3:22
mvePIEBALDconsult13-Feb-11 3:22 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Dave Midgley13-Feb-11 6:06
Dave Midgley13-Feb-11 6:06 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
OriginalGriff13-Feb-11 6:09
mveOriginalGriff13-Feb-11 6:09 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Richard MacCutchan13-Feb-11 6:24
mveRichard MacCutchan13-Feb-11 6:24 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
PIEBALDconsult13-Feb-11 14:58
mvePIEBALDconsult13-Feb-11 14:58 
AnswerRe: Please can someone do me a favour and run a C# test for me Pin
Dave Kreskowiak13-Feb-11 10:59
mveDave Kreskowiak13-Feb-11 10:59 
GeneralRe: Please can someone do me a favour and run a C# test for me Pin
Dave Midgley13-Feb-11 20:19
Dave Midgley13-Feb-11 20:19 
QuestionVariable to be Accessed throughout code [modified] Pin
MWRivera12-Feb-11 16:37
MWRivera12-Feb-11 16:37 
Hi All,

I would like to assign a value to a variable in the Default.aspx.cs section of my code. This value will never change. To prevent having to capture this value throughout the code I want this variable to be accessable throughout the Web Application.

The code looks like this:

public partial Class _Default : System.Web.UI.Page
{
    public static int timeout;    //variable to access

    protected void Page_Load(object sender, EventArgs e)
    {
        //...Get timeout from web.config file here
        timeout = toVal;
    }
}



One of the classes I want to access the static "timeout" variable:

public partial class FormPage : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {

       // How do I access timeout variable here?
    }
}



I had another idea to make a seperate class file out of the code that gets the timeout value from the web.config file. Each time the timeout value is needed call the class and return the timeout. I just feel this would be a waste being that the timeout value will always be the same.

Any help would be really appreciated.
I'm also open to suggestions.
Thank you

modified on Saturday, February 12, 2011 10:51 PM

AnswerRe: Variable to be Accessed throughout code Pin
OriginalGriff12-Feb-11 21:21
mveOriginalGriff12-Feb-11 21:21 
GeneralRe: Variable to be Accessed throughout code Pin
MWRivera13-Feb-11 4:07
MWRivera13-Feb-11 4:07 
GeneralRe: Variable to be Accessed throughout code Pin
OriginalGriff13-Feb-11 5:42
mveOriginalGriff13-Feb-11 5:42 
GeneralRe: Variable to be Accessed throughout code Pin
MWRivera14-Feb-11 15:31
MWRivera14-Feb-11 15:31 
AnswerRe: Variable to be Accessed throughout code Pin
RichardGrimmer15-Feb-11 3:55
RichardGrimmer15-Feb-11 3:55 
GeneralRe: Variable to be Accessed throughout code Pin
MWRivera15-Feb-11 4:03
MWRivera15-Feb-11 4:03 
QuestionSimple calculator Pin
nstk12-Feb-11 7:28
nstk12-Feb-11 7:28 
AnswerRe: Simple calculator PinPopular
Luc Pattyn12-Feb-11 7:37
sitebuilderLuc Pattyn12-Feb-11 7:37 
GeneralRe: Simple calculator Pin
nstk12-Feb-11 11:07
nstk12-Feb-11 11:07 
AnswerRe: Simple calculator Pin
Manfred Rudolf Bihy12-Feb-11 11:19
professionalManfred Rudolf Bihy12-Feb-11 11:19 
AnswerRe: Simple calculator Pin
Luc Pattyn12-Feb-11 11:21
sitebuilderLuc Pattyn12-Feb-11 11:21 
GeneralRe: Simple calculator Pin
nstk13-Feb-11 23:57
nstk13-Feb-11 23:57 
GeneralRe: Simple calculator [modified] Pin
nstk14-Feb-11 3:52
nstk14-Feb-11 3:52 
AnswerRe: Simple calculator Pin
DaveyM6912-Feb-11 12:22
professionalDaveyM6912-Feb-11 12:22 
AnswerRe: Simple calculator Pin
Luc Pattyn12-Feb-11 18:04
sitebuilderLuc Pattyn12-Feb-11 18:04 
GeneralRe: Simple calculator Pin
DaveyM6913-Feb-11 2:48
professionalDaveyM6913-Feb-11 2:48 
AnswerRe: Simple calculator Pin
Luc Pattyn13-Feb-11 3:01
sitebuilderLuc Pattyn13-Feb-11 3:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.