Monday, March 26, 2012

Object reference not set to an instance of an object

Hello, does anyone know were I can set an instance of this object Button1 . I bought this book ASP.NET Solutions 23 case studies by Rick Leienecker and so far all I've been trying to do is debug his examples when I'm trying to learn something but.. maybe thats a good way to learn...

I've tried ..
Button Button1 = new Button();

but I get the same error?

any help appreciated......

-Wiley

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//

InitializeComponent();

base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()

{

this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregionWell,
I selected a page as "select this as Start Page" and -....wa-lah. It works. I didn't think anything was wrong with this code but...... I'm not in Tomcat anymore toto.

thanks anyway
You've got to declare your button as a member of the class.

0 comments:

Post a Comment