I have a simple button:
<asp:Button ID="mybtn" runat="server" Text="My Btn" onclick="mybtn_Click" />
And code behind:
protected MyCustomObject myObject;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
this.myObject = new MyCustomObject();
}
}
protected void mybtn_Click(object sender, EventArgs e)
{
this.myObject.step(1);
}
protected void anotherbtn_Click(object sender, EventArgs e)
{
this.myObject.step(2);
}
The problem: when click, the Page_Load is called and this.myObject is null.
The goal is to call anotherbtn_Click after call mybtn_Click with the same object instance.
How to keep object's context?