Hi,
I am having trouble setting class and session variables in the Page_Load
function in C#. No matter what I set the variables to in Page_Load they
are null when I try to access them in other code on the form.
- I have done this before in VB.Net and it has worked.
- I tried making the variables public (though they shouldn't need to be)
and got the same result
- If I move the same code into an on click event of a button on the web
form it works, so there is nothing in the code itself.
I am running VS 2003 on Windows 2000 Server. Below is some sample code.
If anyone can shed some light on this problem it would be much
appreciated. Also I tried setting breakpoints in Page_Load but the
debugger skips over it. Does anyone know how to get the debugger to step
through the Page_Load function?
private string strConn;
private MyObject obj;
private void Page_Load(object sender, System.EventArgs e)
{
strConn = ConfigurationSettings.AppSettings["ConnectionStr"];
obj = new MyObject(strConn);
Application["ConnectionString"] = strConn;
}
//obj will be undefined and strConn will be null
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!