I'm new in C# I have a question. I'm using telerik and I get an error using an object initialized in the Load_page method.
This is my code:
public partial class Test : System.Web.UI.Page {
private Customer customer;
protected void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack){
customer = new Customer();
customer.Name = "John";
}
}
protected void Button_Click(object sender, EventArgs e) {
MessageBox.Show(customer.Name); //error customer is null
}
}
Why customer is null?