tags:

views:

96

answers:

4

I am looking at two builds of the same app that are supposed to be exactly the same. The app is ASP.NET written in VB.NET. The issue is that on the local build of the app, a simple insert call to the database is adding an entry as it should, yet on a remote deployment of the same build, the same insert is somehow happening twice.

I know this is a very vague question. What I am really wondering is if anyone here has seen something like this happen before, and if the problem somehow exists due to the way the DB (or the table in the DB) is configured.

+2  A: 

Does the page have AutoEventWireUp=True as well as Handles statement for the button click which saves the data?

If yes, try removing AutoEventWireUp=True

If not, try to find the some other way in which the click event is assigned to button twice

Puneet
This is exactly what I keep doing in my early days of ASP.NET development. If you have the AutoEventWireUp + the Handles, it essentially calls the code for the button twice.
BBlake
+2  A: 

One thing that I've run into is people double clicking on a button. This will cause the onclick event to be fired.

Are you the one performing the test through the portal or are you receiving feedback from a client?

EDIT:

The way that I have fixed this in the past is by creating a custom button, that when clicked became disabled until the postback had returned. Here is an example: http://www.codeproject.com/KB/aspnet/oneclickbutton.aspx

Another time I've seen this happen is if someone mashes F5 right after clicking on a button, and resubmitting the postback.

Chris
+2  A: 

You can use SQL Profiler and profile what is happening behind the scenes. See if the same insert is being pushed out.

JonH
A: 

Good advice with the SQL Profiler. I have never used it before but it helped me figure out a little more about what was going on. I now see that the method with the insert statement call inside it is being called twice when it should be called once. The thing that is still amazingly boggling is that it is happening only at the remote server and not at our local one. From what I can tell, the only difference is that the first method call is wrapped with an if statement that checks for some hidden variable that is passed along on postback (that code is old and honestly should probably be removed) and the second method call is fired on a buttonclick event.

So, the hidden var is set to "1" via a little JS snippet on the remote server when the same button with the buttonclick event handler is clicked. However, it is not set to "1" and defaults to "0" on our local server. Now I am left wondering if some windows updates have changed the way that client JS executes (I am vpn-ing into this machine and running our app through IE7 on their server) on their end vs. ours.

Sorry for the lengthy explanation, but I couldn't think of a better way of putting it.

Raggedtoad