ASP.NET null reference exception
Posted
by nanek
on Stack Overflow
See other posts from Stack Overflow
or by nanek
Published on 2010-04-24T15:21:11Z
Indexed on
2010/04/24
15:23 UTC
Read the original article
Hit count: 195
Please help me to figure out what is wrong with this code:
I have ASP.NET page with one button visible.
When user clicks it - it instances MyClass (its implementation is in AppCode directory) and turns invisible (button2 becomes visible).
When I click button2 it raises "Object reference not set to an instance of an object" Exception.
What seems to be the problem?
{
public MyClass noviTest;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
noviTest = new MyClass(TextBox1.Text);
Button1.Visible = false;
Button2.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text=noviTest.getID; //this is the critical line
}
}
Thank You in advance, Regards
© Stack Overflow or respective owner