Button causes Form_Load to fire, before Button_Click

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
P

Paul Aspinall

Hi

I have a form with a button on it.

It seems that when I click the button, it causes Form_load to fire, before
the Button_Click procedure

Does anyone know why??

Thanks
 
This is the firing order of events:

Page_Init
Page_Load
Button_Click
Page_PreRender
<% %> codes on the aspx page.

If you are trying to avoid calling the same code everytime
the page is posted back use :

if (!Page.IsPostBack)
{
// code to execute just on the first load
}

or

If Not Page.IsPostBack Then
' code to execute just on the first load
End If

Hope It Helps

Duray AKAR
 
I have the same problem, but !Page.IsPostBack doesn't help. The buttonClick event updates a value in a SQL database, which must be displayed when the asp page loads. Because PageLoad is called BEFORE the buttonClick method, the page is unable to display the updated value unless the page is refreshed at the end of the buttonClick method, which I would rather avoid doing since it involves 2 post-backs for 1 button click.
 
Back
Top