Why my OnServerValidate sub is never called?

Posted on 2008-11-14
Last Modified: 2012-08-14

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.

    <asp:LinkButton ID="UpdateLinkButton" runat="server" CausesValidation="True"  CommandName="Update" Text="Update" ValidationGroup="EditItemTemplate" />

    <asp:CustomValidator ID="ComplexSaChargeCustomValidator" runat="server"


                         ErrorMessage="Charge unit, charge per unit and calculation type are required for complex charges (if one is used, all must be used)."



                         Display="Dynamic" />




<div class="Warnings">

<asp:ValidationSummary ID="ValidationSummary" runat="server"


                       ValidationGroup="EditItemTemplate" />




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) _


        If Not String.IsNullOrEmpty(ChargeUnitNumericTextBox.Text) _

        And Not String.IsNullOrEmpty(ChargePerUnitNumericTextBox.Text) _

        And Not String.IsNullOrEmpty(CalculationTypeDropDownList.SelectedValue) Then

            arguments.IsValid = True


            arguments.IsValid = False

        End If


        arguments.IsValid = True

    End If


End Sub

Open in new window

Question by:richardhaeger
    LVL 20

    Accepted Solution

    Hi Richard,

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

    Author Closing Comment

    Thank you, your that solved the problem.

    Author Comment

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now