When I include the Regular Expression Validator (REV), the page does not respond to insert a new record into a database. The REV is to validate the file uploaded is an image in jpg or png format

When I remove the REV, it processes the data on the server side

<InsertItemTemplate>
    <asp:FileUpload ID="ImageFileUpload" runat="server" />
    <asp:RequiredFieldValidator
        ErrorMessage='Please upload an image file of type "jpg" or "png"'
        ControlToValidate="ImageFileUpload"
        Text="*"
        runat="server" >
    </asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator 
        ErrorMessage='Image file must be in \"jpg\" or \"png\" format'
        ControlToValidate="ImageFileUpload"
        ValidationExpression ="(?i)^.+(.jpg|.png)$"
        Text="*"
        runat="server">
    </asp:RegularExpressionValidator>

    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" OnClick="InsertButton_Click" />
    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>

I'm expecting for the validation to run, but it does not respond to click

0 Answers