New Found Freakiness for the Day.......

My end users are starting to test the app I'm building and I get this email form one of them telling me that she can fill out the textboxes on the web form and then hit enter several times and it creates many duplicate entries. So I'm thinking "Yeah right". I mean, heck, I put tons of Required Field Validators all over this form. How can you click that button over and over without them firing?

So I check it out for myself, and sure enough, I filled out the form, tabbed to the Submit button, and began hammering away on the Enter key. I think I got to about 17 times before everything finally caught up to me and then the ReqField Validators fired off. SO DANG IT!! my DataGrid now had 17 duplicate entries in it. I asked around if anyone had heard of such an occurance, and one guy had some code that adds an attribute to the button for the onclick that disables the button until Postback. BUT.............guess what? Since I've already got my Field Validators, ASP.NET is generating it's own onclick. So it's not really seeing mine. We looked in the html, and they are both there. We then tried to add the this.disabled code in a manner that would append it to the generated onclick, but apparently it must read our code first and then generate the other onclick last.

What fun fun fun fun fun................................................................................................

So I guess I'll go back and fight with it some more.

Published 18 July 2003 08:50 AM by eking1013

Comments

# William Rohrbach said on 18 July, 2003 09:49 AM
Perhaps you should try using the OnKeyUp and OnMouseUp events to fire the this.disabled javascript call.
# Darrell said on 18 July, 2003 10:25 AM
JavaScript can easily be disabled, so any client-side functionality should be considered after this is dealt with on the server side. What you need is a unique indicator to add to the form's viewstate (a simple timestamp should do) and put that same value in Session for the user. Once the user submits the button the first time, remove the timestamp value from Session and quietly do not process any additional attempts. Or you can add some unique keys to the DataSet if you are using one, and it will throw an error on the second insert attempt.
# Dumky said on 01 August, 2003 08:18 PM
Did you try customizing the form's onSubmit? You could disable the button then.

Please post again if you find a solution, as it is an interesting problem...

Leave a Comment

(required) 
(required) 
(optional)
(required)