By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.