This seems to be a very common problem where by your event handler method gets run twice.
It is caused by VS.NET inserting
2 wireup of the event handler
:
- once in the aspx (HTML) eg:
<asp:button ...="" onclick="btnTest_Click" xmlns:asp="#unknown" />
- and once in the VS.NET generated section (InitializeComponent) eg:
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
The easiest solution, imo, is to simply remove the "OnClick..." HTML markup from the .aspx page.
Eg change this:
<asp:button id="btnTest" runat="server" text="Test" onclick="btnTest_Click" xmlns:asp="#unknown" />
To this:
<asp:button id="btnTest" runat="server" text="Test" xmlns:asp="#unknown" />
Rebuild, and bingo! - 1 event per click.
ripped from here[^]
-KR