在 ASP.Net 中避免使用者重複按下 Button
有時在我們所開發的 Application 中,如果遇到較為複雜的處理程序或者資料庫交易時,會希望一般的 End User 不要重複按下按鍵,避免不斷的 Form Submit,導致交易或者處理程序失敗。
我們可以在 Form Load 事件中設定 Button1 的 Attributes 屬性,並加入以下相關程式碼:
Button1.Attributes("onclick") = "this.disabled = true;" + Me.GetPostBackEventReference(Me.Button1)
沒有留言:
張貼留言