having a slight problem with an ASP.net page of mine. If a user were to double click on a \"submit\" button it will write to the database twice (i.e. carry out the \'onclick
The general approach is twofold.
Serverside:
System.Random), save it in the session, and write it to a hidden form fieldClientside:
Similar to what you have, but probably just hide the button, and replace it with some text like 'submitting'.
The important thing to note, client side, is that the user may cancel the post by hitting 'escape', so you should consider what to do here (depending on how far along they are the token won't be used, so you'll need to bring the button back from being disabled/hidden).
Complete example follows:
C# (includes code to see it in action):
double-click test