Disabling button after click

微信扫一扫,分享到朋友圈

Disabling button after click
Private Function StoreCouponCode() As String
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DBConnectionString").ConnectionString)
Dim sql As New SqlCommand("", con)
Dim sqlGetSlNo As New SqlCommand("SELECT MAX(SlNo) FROM Coupons WHERE CustID=" & Convert.ToInt16(HFCustID.Value) & " AND BusiID=" & Convert.ToInt16(HFBusiID.Value) & " AND OfferID=" & Convert.ToInt16(HFOfferID.Value), con)
Dim sNo, UserID, couponCode, offerCheck As String
Dim slNo As Int16
Try
UserID = getCurrentUserID()
con.Open()
sNo = Convert.ToString(sqlGetSlNo.ExecuteScalar)     'fteches latest serial no for the coupon
If sNo = "" Then
slNo = 0
Else
slNo = Convert.ToInt16(sNo) + 1
End If
couponCode = MakeCouponCode(slNo)
offerCheck = couponCode.Substring(13, 3)
sql.CommandText = "INSERT INTO Coupons VALUES (" & _
HFCustID.Value & "," & HFBusiID.Value & "," & HFOfferID.Value & ",'" & _
Today.Date & "'," & Convert.ToString(slNo) & "," & offerCheck & ",'" & couponCode & "','" & _
UserID & "'," & LblPayInAdv.Text & "," & LblPayLater.Text & ",'" & Convert.ToString(Date.Now) & "')"
sql.ExecuteNonQuery()
con.Close()
Catch ex As Exception
couponCode = "N/A"
Finally
con.Dispose()
sql.Dispose()
End Try
Return couponCode
End Function
Protected Sub CmdGetCoupon_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles CmdGetCoupon.Click
If User.Identity.Name = "" Then
LblMessage.Text = "You need to login first!"
Exit Sub
End If
Dim couponCode As String = StoreCouponCode()
Response.Redirect("~/Coupon.aspx?CouponCode=" & couponCode, True)
End Sub

When the user clicks on the CmdGetCoupon
it takes some time to redirect..so the user clicks on the CmdGetCoupon
more than once,which results in multiple coupon generation from a single user account.

I want to display a message “Please Wait While Your Coupon Is Being Generated” and disable the CmdGetCoupon
so that the user cannot click multiple times….Any Ideas??How to do this??

Do this in javascript – use the OnClientClick
to call a function that disables the passed in form element.

// On button
... OnClientClick="DisableMe(this);" ...
// Javascript
function DisableMe(elem)
{
elem.disabled = true;
// more code to show message
}

微信扫一扫,分享到朋友圈

Disabling button after click

A Beginner’s Guide to Grabbing and Analyzing Salary Data in Python

上一篇

Given a set of ids, remove all documents with those ids

下一篇

你也可能喜欢

Disabling button after click

长按储存图像,分享给朋友