【问题标题】:Button click is not firing in a multiview?按钮单击未在多视图中触发?
【发布时间】:2013-04-30 06:46:04
【问题描述】:

我有一个 aspx 页面,其中包含 4 个多视图控件和每个控件中的不同视图。在详细信息视图的第一个视图中,我正在输入一些发票详细信息并检查数据库中的数据行是否与付款详细信息一起出现。

代码工作正常,直到它显示数据行以及支付控件,但支付控件(用户控件)没有正确触发其验证控件(必需的字段和正则表达式控件)。除了单击按钮之外,也不会触发验证码,尽管如果我输入正确的详细信息,它会保存数据。

你们中的任何人都可以看看下面的代码并告诉我其中有什么问题吗?

    Protected Sub cmdPay_Click(sender As Object, e As EventArgs) Handles cmdPay.Click
        mvwDetails.Visible = False
        Try

            '  If Not Page.IsPostBack Then

            If Me.CreditCard1.CCNumber.Length < 14 Or Me.CreditCard1.CCNumber.Length > 16 Then
                Me.lblError.Text = "Please enter Valid Card details"

            Else
                Dim result As DateTime = Conversions.ToDate("1/1/1900")
                If Not DateTime.TryParse(Me.CreditCard1.CCExpireDate, result) Then
                    Me.lblError.Text = "Please enter the Valid Expiry Date"
                    Me.lblError.Visible = True
                    ' mvwMakePayment.Visible = True
                    ' mvwMakePayment.SetActiveView(vwMakePayment)
                ElseIf DateTime.Compare(result, DateTime.Today) < 0 Then
                    Me.lblError.Text = "Please enter the Valid Expiry Date"
                    Me.lblError.Visible = True
                    ' mvwMakePayment.Visible = True
                    ' mvwMakePayment.SetActiveView(vwMakePayment)
                ElseIf Me.CreditCard1.CVV Is Nothing Or Not Versioned.IsNumeric(DirectCast(Me.CreditCard1.CVV, Object)) Then
                    Me.lblError.Text = "Invalid credit card details."
                    Me.lblError.Visible = True
                    ' mvwMakePayment.Visible = True
                    ' mvwMakePayment.SetActiveView(vwMakePayment)
                ElseIf Strings.Len(Me.CreditCard1.CVV) > 4 Then
                    Me.lblError.Text = "Invalid cvv number."
                    Me.lblError.Visible = True
                    ' mvwMakePayment.Visible = True
                    ' mvwMakePayment.SetActiveView(vwMakePayment)
                Else
                    Dim OrderID As String
                    OrderID = grdMain.Items(0).Cells(1).Text
                    If Page.IsValid Then
                        Dim dtOrderPerson As DataTable = Me.DataAction.GetDataTable("SELECT o.ID,o.BillToID,o.ShipToName,o.BillToCompanyID,o.OrganizationID,o.InvoiceNumber,OrderDate,GrandTotal,Balance,CurrencySymbol,NumDigitsAfterDecimal FROM " & Convert.ToString(Me.Database) & "..vwOrders o INNER JOIN " & Convert.ToString(Me.Database) & "..vwCurrencyTypes ct ON o.CurrencyTypeID=ct.ID where  Balance > 0 AND o.OrderStatus <> 'Cancelled' And o.ID=" & CLng(OrderID), IAptifyDataAction.DSLCacheSetting.BypassCache)
                        If dtOrderPerson.Rows.Count > 0 Then
                            Me.mvwMakePayment.SetActiveView(vwMakePayment)
                            Me.mvwMakePayment.Visible = True
                            'lblkaj.Text = "returned a record"
                            FirstName = dtOrderPerson.Rows(0).Item("ShipToName").Trim.ToString()
                            Dim entityObject As AptifyGenericEntityBase = Me.AptifyApplication.GetEntityObject("Payments", -1)
                            entityObject.SetValue("EmployeeID", DirectCast(1, Object)) 'No web user is returned as the data is based on orderid and companyid ,  Employee id of the web user is 1 hence using the same 
                            ' entityObject.SetValue("EmployeeID", DirectCast(grdMain.Items(0).Cells(0).ToString(), Object))
                            entityObject.SetValue("PersonID", DirectCast(dtOrderPerson.Rows(0).Item("BillToID").ToString, Object))
                            entityObject.SetValue("CompanyID", DirectCast(dtOrderPerson.Rows(0).Item("BillToCompanyID").ToString, Object)) 'Me.dtOrders.Rows(0).Item("BilllToCompanyID").ToString
                            entityObject.SetValue("PaymentDate", DirectCast(DateTime.Today, Object))
                            entityObject.SetValue("DepositDate", DirectCast(DateTime.Today, Object))
                            entityObject.SetValue("EffectiveDate", DirectCast(DateTime.Today, Object))
                            entityObject.SetValue("PaymentTypeID", DirectCast(Me.CreditCard1.PaymentTypeID, Object))
                            entityObject.SetValue("CCAccountNumber", DirectCast(Me.CreditCard1.CCNumber, Object))
                            entityObject.SetValue("CCExpireDate", DirectCast(Me.CreditCard1.CCExpireDate, Object))
                            entityObject.SetAddValue("_xCCSecurityNumber", DirectCast(Me.CreditCard1.CVV, Object))
                            entityObject.SetValue("PaymentLevelID", DirectCast(1, Object))
                            '  entityObject.SetValue("Comments", DirectCast("Created through the CGI e-Business Suite", Object))
                            entityObject.SetAddValue("_xConvertQuotesToRegularOrder", DirectCast("1", Object))
                            Dim genericEntityBase As AptifyGenericEntityBase = entityObject.SubTypes("PaymentLines").Add()
                            genericEntityBase.SetValue("Amount", DirectCast(dtOrderPerson.Rows(0).Item("Balance").ToString, Object))
                            genericEntityBase.SetValue("OrderID", DirectCast(dtOrderPerson.Rows(0).Item("ID").ToString, Object))
                            genericEntityBase.SetValue("Comments", DirectCast("Invoice paid from web", Object))
                            If entityObject.Save(True) Then
                                Dim dtPyments As DataTable = Me.DataAction.GetDataTable("select P.ID,P.PersonID,P.CompanyID,P.PaymentDate,Pl.OrderID,Pl.Amount from payment P inner join paymentdetail pl on P.id=Pl.paymentid where pl.orderid=" & CLng(OrderID))
                                ' Me.grdReceipt.DataSource = DirectCast(dtPyments, Object)
                                '  grdReceipt.DataBind()
                                '  grdReceipt.Visible = False
                                lblInvo.Text = OrderID


                                lblPyNo.Text = dtPyments.Rows(0).Item("ID").ToString()
                                lblAmount0.Text = dtPyments.Rows(0).Item("Amount").ToString()
                                Dim amnt As Double = lblAmount0.Text
                                amnt = FormatNumber(amnt, 2)
                                lblAmount0.Text = amnt

                                ' EmailID = txtEmail.Text.Trim.ToString
                                mvwMakePayment.Visible = False
                                mvwMessage.Visible = True
                                mvwMessage.SetActiveView(vwSuccessMessage)
                                Dim mailBody As New StringBuilder
                                mailBody.Append("Dear " & FirstName & ", ").AppendLine(Environment.NewLine)
                                mailBody.Append("Thank you, for your payment of invoice number " & lblInvo.Text & ". $ " & lblAmount0.Text & " " & "has been deducted from your nominated credit card. ").AppendLine(Environment.NewLine)
                                mailBody.Append("Your receipt number is " & lblPyNo.Text & ". Please keep this for your reference.").AppendLine(Environment.NewLine)
                                mailBody.Append("If you have any queries regarding this payment please contact our Accounts Receivable department on 04456666 and reference your invoice number.").AppendLine(Environment.NewLine)

                                ' mailBody.Append("Receipt Number :  " & lblPyNo0.Text)
                                sendEmail("Accounts Department", lblEmail.Text, "Payment Receipt’", mailBody.ToString)
                                ' lblEmail.Text = EmailID
                            Else
                                mvwMessage.Visible = True
                                mvwMessage.SetActiveView(vwFailedMessage)
                            End If
                        End If
                    End If
                End If
            End If
            'End If
        Catch ex As ThreadAbortException
            ExceptionManager.Publish(ex)
            ProjectData.SetProjectError(DirectCast(ex, Exception))
            ProjectData.ClearProjectError()
        Catch ex As Exception
            ProjectData.SetProjectError(ex)
            ExceptionManager.Publish(ex)
            ProjectData.ClearProjectError()
        End Try
    End Sub

【问题讨论】:

  • 请添加asp代码

标签: asp.net vb.net controls


【解决方案1】:

检查您是否有适当的验证组,如果您有条件地设置原因验证也可能发生,如果有,请检查。

【讨论】:

  • 您好 Vinay,我没有在任何验证控件上设置验证组?这是正常的做法吗? .此外,我有条件验证来检查信用卡详细信息..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-02
  • 1970-01-01
  • 2020-03-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多