Why my OnServerValidate sub is never called?

Hello,

I am almost sure this code was running alright a couple of weeks ago.

I remember it was not working but then I removed the ControlToValidate property and it started to work perfectly.

But now it is broken again. Could you check my code below?

When I put a break in the validation procedure I can see the sub it is never executed. So I know the problem is not in the validation sub (which I already tested and works correctly) but in the fact that it is never executed.

Please help.

Thanks in advance.
<EditItemTemplate>
    <asp:LinkButton ID="UpdateLinkButton" runat="server" CausesValidation="True"  CommandName="Update" Text="Update" ValidationGroup="EditItemTemplate" />
    <asp:CustomValidator ID="ComplexSaChargeCustomValidator" runat="server"
                         OnServerValidate="ValidateComplexSaCharge"
                         ErrorMessage="Charge unit, charge per unit and calculation type are required for complex charges (if one is used, all must be used)."
                         Text="*" 
                         ValidationGroup="EditItemTemplate"
                         Display="Dynamic" />
</EditItemTemplate>
 
-----------------------------------------------------------------------------------------------------
 
<div class="Warnings">
<asp:ValidationSummary ID="ValidationSummary" runat="server"
                       CssClass="ValidationSummary"
                       ValidationGroup="EditItemTemplate" />
</div>
 
------------------------------------------------------------------------------------------------------
 
Sub ValidateComplexSaCharge(ByVal source As Object, ByVal arguments As ServerValidateEventArgs)
 
    Dim ChargeUnitNumericTextBox As WebUserControls_NumericTextBox = SaChargeGridView.Rows(SaChargeGridView.EditIndex).FindControl("ChargeUnitNumericTextBox")
    Dim ChargePerUnitNumericTextBox As WebUserControls_NumericTextBox = SaChargeGridView.Rows(SaChargeGridView.EditIndex).FindControl("ChargePerUnitNumericTextBox")
    Dim CalculationTypeDropDownList As DropDownList = SaChargeGridView.Rows(SaChargeGridView.EditIndex).FindControl("CalculationTypeDropDownList")
 
    If Not String.IsNullOrEmpty(ChargeUnitNumericTextBox.Text) _
    Or Not String.IsNullOrEmpty(ChargePerUnitNumericTextBox.Text) _
    Or Not String.IsNullOrEmpty(CalculationTypeDropDownList.SelectedValue) _
    Then
        If Not String.IsNullOrEmpty(ChargeUnitNumericTextBox.Text) _
        And Not String.IsNullOrEmpty(ChargePerUnitNumericTextBox.Text) _
        And Not String.IsNullOrEmpty(CalculationTypeDropDownList.SelectedValue) Then
            arguments.IsValid = True
        Else
            arguments.IsValid = False
        End If
    Else
        arguments.IsValid = True
    End If
 
End Sub

Open in new window

richardhaegerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Juan_BarreraCommented:
Hi Richard,

What happens if you move the CustomValidator outside the Template? Can you please try this?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
richardhaegerAuthor Commented:
Thank you, your that solved the problem.
0
richardhaegerAuthor Commented:
One thing I cannot understand is I have 4 other forms with custom validators inside templates and all work correctly, only this one fails. Any idea why?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.