asp.net正则表达式验证器无回发

时间:2019-04-21 16:51:18

标签: c# asp.net webforms

当我包含正则表达式验证器(REV)时,页面不响应将新记录插入数据库。 REV用于验证上传的文件是jpg还是png格式的图像

当我删除REV时,它将在服务器端处理数据

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

我希望验证能够运行,但是它对点击没有响应

0 个答案:

没有答案