B
Brad Baker
I have an asp.net/csharp application that requires a particular variable to
work properly. This variable is usually passed via a query string in the URL
when the application is first run but under certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.
Is there some way I can set a query string on page_load OR is there some way
I can use a global variable which is accessible throughout my application
instead? In pseudo code something like:
public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}
protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}
Hopefully this makes sense - for clarity sake I have tried to simplify my
situation as much as possible.
Thanks
Brad
work properly. This variable is usually passed via a query string in the URL
when the application is first run but under certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.
Is there some way I can set a query string on page_load OR is there some way
I can use a global variable which is accessible throughout my application
instead? In pseudo code something like:
public void Page_Load(object sender, EventArgs e)
{
if (querystring == null)
{
global myvariable = "somevalue";
} else {
global myvariable = querystring;
}
}
protected void dostuff(object sender, EventArgs e)
{
if (myvariable == "foo")
{
// do stuff
}
}
Hopefully this makes sense - for clarity sake I have tried to simplify my
situation as much as possible.
Thanks
Brad