是否可以在异步回发期间更改事件处理程序?
我试过这个
RemoveHandler CloseModalButton.Click, AddressOf MakePayment
AddHandler CloseModalButton.Click, AddressOf MakeBankPayment
但显然它需要在发生变化之前进行回发。
还有其他办法吗?
由于
编辑 - 添加了代码!
Private Sub BankOneOff_ConfirmPayments()
Try
RemoveHandler CloseModalButton.Click, AddressOf MakePayment
AddHandler CloseModalButton.Click, AddressOf MakeBankPayment
Dim vAmount As Decimal = inputBankOneOffAmount.Value
Dim vBody As String = "<p>This is will make a one time ACH (eCheck) payment from your bank account</p>"
vBody += "<p>The amount being debited is $" & Format(vAmount, "###,##0.00") & "</p>"
If Session("ServiceCharge") = True Then
Dim vChargePercent As Decimal = Session("ACHFee")
Dim vCharge As Decimal = Math.Round((vAmount * vChargePercent) / 100, 2)
vBody += "<p> A Service Charge of $" & Format(vCharge, "###,##0.00") & " will be added</p>"
vBody += "<p> The total that will be debited from your account is $" & Format(vCharge + vAmount, "###,##0.00") & "</p>"
End If
Dim SB As New StringBuilder
SB.Append("$(document).ready(function(){")
SB.Append("$('#PaymentConfirmationModal').modal();")
SB.Append("var vBody = document.getElementById('PaymentConfirmationText');")
SB.Append("vBody.innerHTML = '" & vBody & "';")
SB.Append("});")
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "CardWindowOpen", SB.ToString, True)
Catch ex As Exception
Dim vError As New SendError
vError.MailError("2032", PageName, ex)
End Try
End Sub