page_load fires two times

  • Thread starter Thread starter Arjen Hoekstra
  • Start date Start date
A

Arjen Hoekstra

Hello,

I've an ASP.NET-page in which there are some fields with data from a
database and an OK-button. When the page loads (so this code is in the
Page_Load-part) some data is send to the database (with MySql
'INSERT'-statement). But when I click the OK-button I see the same data is
being resend to the database. So Page_Load is fired again while it
shouldn't! Any-one knows how this could be happening? Thanks in advance for
any help!

Arjen
 
Hi,

Page_Load will fire even on post-back (that is, when you click OK button).
Use Page.IsPostBack property to check whether the current execution is
because of post back or initial load and do things accordingly.

HTH.

Hello,

I've an ASP.NET-page in which there are some fields with data from a
database and an OK-button. When the page loads (so this code is in the
Page_Load-part) some data is send to the database (with MySql
'INSERT'-statement). But when I click the OK-button I see the same data is
being resend to the database. So Page_Load is fired again while it
shouldn't! Any-one knows how this could be happening? Thanks in advance for
any help!

Arjen
 
Back
Top