Thursday, March 22, 2012

System.NullReferenceException: Object reference not set to an instance of an object.

Hi, the following code received run-time error (NullReferenceException), and I don't know how to troubleshoot it :(
under Page_Load at Default.aspx:
loginBox.LoginAuthenticated += new LoginAuthenticatedEventHandler(Succeeded)
under my LoginBox.ascx.cs, I setup the object like the followings:
public delegate void LoginAuthenticatedEventHandler(object sender, LoginAuthenticatedEventArgs e);
public event LoginAuthenticatedEventHandler LoginAuthenticated;
public class LoginAuthenticatedEventArgs : EventArgs
{
public int UsrID;
}//end class LoginAuthenticatedEventArgs

under my Page_Load of my LoginBox.ascx.cs, I load my object like this:
if (LoginAuthenticated != null)
{
LoginAuthenticatedEventArgs eventInfo = new LoginAuthenticatedEventArgs();
eventInfo.UsrID = Int32.Parse(txtUser.Text);
LoginAuthenticated(Page, eventInfo);
}//end if (LoginAuthenticated != null)

I thought I had the object reference to the correct place, what else am I missing?
TIA
..resoloved: http://forums.asp.net/1089126/ShowPost.aspx

0 comments:

Post a Comment