ArticleDirectory
- Problem
- The final solution utilizes the unique ID feature.
Problem
When a user clicks the charge button in the newly-developed property charging system, if the user clicks the charge button multiple times, two receiving orders will be generated. If the user finds a problem, he will pass
Http://www.cnblogs.com/happyhippy/archive/2010/08/15/1800289.html
Added
Lnkcharge. attributes [ " Onclick " ] = This . Getpostbackeventreference ( This . Lnkcharge) + " ; This. Disabled = true; " ; // Prevent repeated submission
The local machine passed the test, but the user still had repeated receipts the next day...
The final solution utilizes the unique ID feature.
I feel that this kind of control is not very safe on the client, so I put the solution in the background.CodeBut the buttons at the front end still have
Because the table we created is ID using guid, we can go to the page! Ispostboack generates a temporary guid and stores it in viewstate.
If ( ! Ispostback)
{
Tempid = Guid. newguid (). tostring ();
Then, use the guid as the ID when inserting the receipt ticket data in the billing button event. Because the ID cannot be repeated, the duplicate guid will not be inserted.
It is recommended to determine whether the guid already exists before the current insertion.
Model. collectioninfo collection = New Model. collectioninfo ();
Collection. ID = New GUID (tempid ); If (New BLL. bcollection (). getcount (new model. searchclass. collectionsearch (). Id (tempid)> 0)
{
Scriptalert ("the billing items on this page have been charged and cannot be charged repeatedly ");
Return;
}
Guid collectionid = guid. empty;
Try
{
Collectionid = new BLL. bcollection (). insert (Collection );
}
Catch
{
Scriptalert ("the billing items on this page have been charged and cannot be charged repeatedly ");
Return;
}