title: Run function after button events
body: <p>Buttons in asp.net automatically refresh the page. Before the button events are called, the default Page_Load function is called (I think).</p>
  
  <p>I'm looking for a way to call a function after all of the button events are called.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I want to always call the function, even if there's no button pressed. So putting the function in the button event doesn't work.</p>
  
  <p><strong>Creating a button</strong></p>
  
  <pre><code>ImageButton enc2Button = Hardwarerecorders.DeviceManager.getEncStatusImage(d, "res/", false);
  </code></pre>
  
  <p><strong>This is the click event</strong></p>
  
  <pre><code>enc2Button.Click += new ImageClickEventHandler(startEnc2);
  </code></pre>
  
  <p><strong>Button event function</strong></p>
  
  <pre><code>void startEnc2(object sender, EventArgs e)
  {
      ImageButton button = (ImageButton)sender;
      int arrayIndex = Int32.Parse(button.Attributes["index"]);
      Hardwarerecorders.DeviceManager.startEnc((Hardwarerecorders.Device)devices[arrayIndex], false);
  }
  </code></pre>