page_load fires two times

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
 
S

Shiva

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top