In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to prevent users from submitting data repeatedly when registering or clicking buttons". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
Asp.net realizes that the button is not available after clicking the button and submit it.
The copy code is as follows:
Background code:
The copy code is as follows:
Protected void Button1_Click (object sender, EventArgs e)
{
Thread.Sleep (3000)
Response.Write ("123213
")
Response.Write ("123213
")
Response.Write ("123213
")
}
If there are many buttons on the page, you can do it in another way:
Background page_load code:
The copy code is as follows:
This.BtnSend.Attributes.Add ("onclick", this.GetPostBackEventReference (this.BtnSend) + "; this.disabled=true;")
The code of the front desk button:
The copy code is as follows:
Because after the this.disabled of the control is set, the control is disabled and cannot call the background event method in the postback, so you must use GetPostBackEventReference to call back the background event method before calling disabled=true.
ASP.NET UseSubmitBehavior attribute
Definition and usage
The UseSubmitBehavior property specifies whether the button control uses the built-in submission function of the client browser or the postback mechanism of ASP.NET.
This property is set to TRUE if the control uses the browser's submission mechanism. Otherwise, FALSE. The default value is TRUE.
When set to FALSE, ASP.NET adds a client script to return the form.
When the UseSubmitBehavior property is false, the control developer can use the GetPostBackEventReference method to return the client postback event of Button. The string returned by the GetPostBackEventReference method contains the text of the client function call and can be inserted into the client event handler.
Grammar
Example
The following example uses ASP.NET 's postback mechanism:
The copy code is as follows:
Sub SubmitBtn (obj As Object, e As EventArgs)
LblMsg.Text = "Submitted using the ASP.NET postback mechanism."
End Sub
Click the button:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.