Problem background:
On-Hand KPI classification rating system, the page's Submit button is made with LinkButton or button. When a large number of users at the same time online access to the site, the application server CPU occupied 100% of the bad situation, the page will not move, the user unknown continuous Click submit button repeated submission, resulting in a large number of data duplication in the database.
In fact, even if the server did not collapse, quickly and frequently click the Submit button, there will be repeated submission of the problem.
Tried: 1 to set the enabled attribute of the Submit button in the Click event of the Submit button Enabled = FALSE; , this property is not valid until the new page is taken, and the problem persists;
2 in the client event JS set the Submit button disabled disabled = TRUE; , the service-side event for the submit button will no longer execute;
3 also tried to click the Submit button immediately after the pop-up Div mask layer, the effect is not ideal, the problem still exists;
4 adds an HTML button, and hides the submit button, clicks the HTML button to submit, makes the HTML button unavailable in the client event of the HTML button (prevents duplicate submissions), triggers the server event for the Submit button, and the HTML button automatically becomes available after the page postback. This method is feasible, if there are deficiencies or better methods, but also hope that we do not hesitate to enlighten.
Solution Idea:
1 In addition to the Submit button LinkButton (ID is lbtsave), add an HTML button
|
<input type= "button" id= "Htmlsave" value= "Submit" onclick= "Singlesubmit ()"/> |
2) Hide Lbtsave, note that can not set the Lbtsave Visible property is false to achieve hidden, otherwise Lbtsave server event Lbtsave_click will not be triggered; possible way: Use <div style= "display : none; " ></div> contains lbtsave to implement hidden or directly with #lbtSave {Display:none;}
3)
|
<script type= "Text/javascript" >
Functionsinglesubmit ()
{
document.getElementById ("Htmlsave"). Disabled =true;
document.getElementById ("Lbtsave"). Click ();
}
</script> |
4) Click Htmlsave, execute Singlesubmit () method, make Htmlsave unavailable (prevent duplicate commit), trigger Lbtsave_click Event
5 after the page postback, that is, after the Lbtsave_click event is executed, the htmlsave automatically becomes available.
In order to simulate the real situation, 5s thread dormancy Thread.Sleep (5000) was added to the Lbtsave_click event;.