'Validation works twice

In my WCF application I have a validation.

It is working fine - execution comes into cvBookingTypeS4AProjects_ServerValidate method, but then it comes into it for the second time and this time Text value is empty but after first time it contained ID I need.

How to prevent it from executing for the second time?

.cs

<asp:DropDownList 
    ID="ddlBookingTypeS4AProjects" 
    runat="server" 
    SelectedValue='<%# Bind("CoReqLineBoTyInS4ProjProvider") %>'
    DataSourceID="odsBookingTypeS4Projects" 
    DataValueField="BoTyS4ProjNumber" 
    DataTextField="BoTyS4ProjName"
    Enabled="true" 
    Width="450" 
    AutoPostBack="true" 
    ValidationGroup="CoReqLine"
    OnDataBinding="ddlBookingTypeS4AProjects_DataBinding"
    OnDataBound="ddlBookingTypeS4AProjects_DataBound" />

<asp:CustomValidator 
    ID="cvBookingTypeS4AProjects" 
    runat="server" 
    Text='<%#Eval("IDContractRequestLine")%>'
    ControlToValidate="ddlBookingTypeS4AProjects" 
    ErrorMessage="S4 project value selection is required"
    OnServerValidate="cvBookingTypeS4AProjects_ServerValidate" 
    ValidationGroup="CoReqLine"
    ValidateEmptyText="true"/>

.ascx.cs

protected void cvBookingTypeS4AProjects_ServerValidate(object source, ServerValidateEventArgs args)
{
    CustomValidator cv = (CustomValidator)source;

    // Here in the Text field I have value after first execution of the method
    Int32.TryParse(cv.Text, out int contractRequestLineId);

    if (contractRequestLineId == 0)
        args.IsValid = false;
    else
        args.IsValid = true;
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source