I really some need help with this compare validator, which isn't working properly.

Discussion in 'ASP .Net' started by TN Bella, Jul 2, 2004.

  1. TN Bella

    TN Bella Guest

    Hi,

    I am trying to get my compare validator to fire properly...Since I have
    panels the validator wouldn't work properly, the app would fire right
    but would insert the data regardless and the user couldn't fix an error
    if they had an error. So I added another sub and fixed the panels, but
    the compare validator still doesn't work right.

    Right now the validator pops up with the error that the two values
    (txtAcctAmtSum and txtInvAmt) are not equal, when the correct amount is
    entered, the error goes away (tabbing to next fields), but when the user
    clicks the button to go to the next panel, the error displays again the
    user is stuck.

    The txtAcctAmtSum is an added value of all textboxes (txtAcctAmt to
    txtAcctAmt14). The txtAcctAmtSum is activated by <asp:TextBox
    id="txtAcctAmt8" onblur="this.onChange();" runat="server"
    AutoPostBack="true" ontextchanged="doCalc"></asp:TextBox>.
    I hope someone can make my day and help me fix this problem. I need to
    finish this project! Thanks in advance for the assistance.



    <asp:panel id="pnl4" runat="server" Height="742px" visible="false">
    <asp:textbox id="txtAcctAmtSum" runat="server"></asp:textbox>
    <asp:CompareValidator id="cvAcctAmt" runat="server"
    ErrorMessage="Invoice Amount Out of Balance"
    ControlToValidate="txtAcctAmtSum" Type="Currency"
    ControlToCompare="txtInvAmt">Invoice Amount Out of Balance with Account
    Amount Total.</asp:CompareValidator>


    <asp:panel id="pnl3" runat="server" Height="742px" visible="false">
    <asp:textbox id="txtInvAmt" runat="server" Width="188px"></asp:textbox>


    'This section activated when the button is clicked, for compare
    validator.
    Sub checkBalance(Source as Object, E as EventArgs)
    if cvAcctAmt.IsValid then
    doInsert(source,e)
    else
    pnl1.visible="false"
    pnl2.visible="false"
    pnl3.visible="false"
    pnl4.visible="true"
    pnl5.visible="false"
    end if

    End Sub

    'This section displays the entered information back to the user and
    inserts data to the tables.
    Sub doInsert(Source as Object, E as EventArgs)

    pnl1.visible="false"
    pnl2.visible="false"
    pnl3.visible="false"
    pnl4.visible="false"
    pnl5.visible="true"

    This could be an issue with the compare validator...the last textbox
    (txtAcctAmt14) as an error on the page displayed on the toolbar when I
    click in the box....Someone please help with this problem - please!

    Sub doCalc(Source as Object, E as EventArgs)
    'Adding account amounts and compare total to invoice amount

    Dim strControlName As String
    Dim i As Int16
    Dim sum as Double
    sum = Val(txtAcctAmt.Text)
    For i = 1 To 14
    strControlName = "txtAcctAmt" & i
    Dim TB As TextBox = CType(Me.FindControl(strControlName),
    TextBox)
    If TB.Text <> "" Then
    sum = sum + Val(TB.Text)
    End If
    Next
    txtAcctAmtSum.text= sum.ToString("C")
    End Sub

    Please help....I really need to get through this part. Thank you!!


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    TN Bella, Jul 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robbo
    Replies:
    0
    Views:
    314
    Robbo
    Oct 30, 2003
  2. =?Utf-8?B?Q2hyaXM=?=

    Help Help. I really need some help with this

    =?Utf-8?B?Q2hyaXM=?=, Jan 31, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    535
    =?Utf-8?B?SmFzb24gVmVybWlsbGlvbg==?=
    Jan 31, 2007
  3. Replies:
    30
    Views:
    948
    Arne Vajhøj
    Feb 10, 2008
  4. Steve Mauldin
    Replies:
    0
    Views:
    120
    Steve Mauldin
    Feb 6, 2004
  5. Replies:
    3
    Views:
    79
    Evertjan.
    Sep 3, 2006
Loading...

Share This Page