locked
OnServerValidate not firing for custom validator RRS feed

  • Question

  • User1888916955 posted
    Hi,
    I am creating a webform thru xslt. There are no of textboxes and and reqfield validators , range validators etc inthe web form. All other controls are also working fine. All the validations for the requiredfield validator, range validator works fine.. Only the custom validator is not working .. OnServerValidate ="test" does not fire for the custom validator.  Can anyone help me find out why this is not firing
    I am checking page.validate on Page load
    if (IsPostBack)
    {
    Page.Validate();
    This is the xslt  
    <xsl:for-each select="validation/validator">
    <xsl:if test="@type='required'">
    <asp:RequiredFieldValidator ErrorMessage="{text}" runat="server"
    ControlToValidate="{$current_id}" ForeColor="{forecolor}" Display="{display}"/>
    </xsl:if>
    <xsl:if test="@type='compare'">
    <xsl:variable name="comparevalue">
    <asp:value-of select="valuetocompare" />
    </xsl:variable>
    <asp:CompareValidator ErrorMessage="{text}" runat="server"
    ControlToValidate="{$current_id}" ValueToCompare="{valuetocompare}" Operator="{operator}" ForeColor="{forecolor}" Display="{display}"/>
    </xsl:if>
    <xsl:if test="@type='range'">
    <asp:RangeValidator ErrorMessage="{text}" runat="server"
    MaximumValue="{max}" MinimumValue="{min}" ControlToValidate="{$current_id}" Type="Integer" ForeColor="{forecolor}" Display="{display}"/>
    </xsl:if>
    <xsl:if test="@type='custom'" >
    <asp:CustomValidator ErrorMessage="{text}" runat="server" ControlToValidate="{$current_id}" OnServerValidate="test1" ForeColor="{forecolor}" ValidateEmptyText="True" EnableClientScript="False" />
    </xsl:if>
    </xsl:for-each>
    Monday, March 12, 2007 9:56 AM

All replies

  • User-1004041437 posted

    Hi there,

                  I think it's not working because you need to bind your event handler (test1) to the "OnServerValidate" event on runtime so I guess that you will need to use reflection to solve that. Remember that Asp.net is doing that task automatically for you.

     

    Regards,

    Fernando

     

    Tuesday, March 13, 2007 4:35 PM