-2

I want to know what happens when same button clicked before completion of execution of code under click event in asp.net web application.Does the request goes in queue or it get disturbed by same event by other user.

JSK NS
  • 3,346
  • 2
  • 25
  • 42
Mayur Pawar
  • 107
  • 2
  • 16

2 Answers2

2

Basically it depends on the action you are going to perform. if you are inserting values into a database, it could cause duplicate entries but If you are making some complex operations on button click then multiple clicks can cancel the process also.

Swati Gupta
  • 546
  • 3
  • 8
  • yes i am using insert statement but data will be different by different users.And also i am using two insert statements in it and using primary key(out parameter) from of first insert statement in another insert statement.So confused what to do .because if one user click submit button with his data and execution is in between two insert statements and another user clicks submit button with his data how can i handle situation. – Mayur Pawar Nov 06 '14 at 11:32
2

You must understand asp.net page lifecycle. When you're clicking button you;re not only fire some event but also send your web form to the server.
So if you fast enough to double click or your form is slow enough, you will send your form to the server twice.
Result of this could be completely different depend of the code executing at this moment. Normally nothing bad will happen between your first click and first time event fired, but as I told it depends of the code executing by this click.

DavidWhitney
  • 4,290
  • 4
  • 24
  • 30
andrey.shedko
  • 3,128
  • 10
  • 61
  • 121
  • i am not asking about double click by same user .Click by another user on same application and from different machine. – Mayur Pawar Nov 06 '14 at 11:47
  • You must clarify your question like "What's going to be if insert two records to database at the same time." – andrey.shedko Nov 06 '14 at 11:52
  • This question is more about SQL, altough you can check also in c# is the record exist, but it's simpler to do trigger somethinng like that http://stackoverflow.com/questions/17442901/how-to-avoid-duplicate-values-for-insert-in-sql – andrey.shedko Nov 06 '14 at 11:55
  • dear @addrey.shedko your not getting my question. – Mayur Pawar Nov 06 '14 at 12:13