Maybe using the
Page_Unload
event to handle logic when a page is exited. The event is raised after the page has been fully rendered and sent to the client
static int x;
protected void Page_Load(object sender, EventArgs e)
{
x = 0;
}
protected void Button8_Click(object sender, EventArgs e)
{
x = x + 6;
}
protected void Button7_Click(object sender, EventArgs e)
{
x = x - 6;
}
protected void Page_Unload(object sender, EventArgs e)
{
x = 0;
}