Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Why my OnServerValidate sub is never called?

Posted on 2008-11-14
Medium Priority
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
  • 2
LVL 20

Accepted Solution

Juan_Barrera earned 2000 total points
ID: 22966002
Hi Richard,

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

Author Closing Comment

ID: 31517026
Thank you, your that solved the problem.

Author Comment

ID: 22980758
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?

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

580 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