Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Double clicking on button in design view produces wierd behaviour

$
0
0

Hello,

I have a button on a form which writes data to a database. Code works fine. When I'm in design view in Visual Studio however, and double-click on the button to go to the underlying code, something I've not seen before happens.

Normally the code would look like this:

<VB>

Protected Sub btnSaveToDB_Click(sender As Object, e As EventArgs) Handles btnSaveToDb.Click

</VB>

Double-clicking on the button in design view, however, produces this:

<VB>

Protected Sub btnSaveToDB_Click(sender As Object, e As EventArgs) Handles btnSaveToDb.Click, btnSaveToDb.Click

</VB>

and so on. What's really strange is that the code would then be executed twice! I am using the code to write data from one table to another and was puzzled by why twice the number of records as I expected was being saved. It took a while before I saw the problem.

My question is why is this behaviour occurring and how do I prevent it?

Thanks for your help.


Viewing all articles
Browse latest Browse all 3509

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>