FileUpload的RequiredFieldValidation

时间:2014-07-07 18:48:44

标签: c# asp.net csv requiredfieldvalidator

我的代码如下所示:

 <asp:Label ID="importLabel" runat="server" Text="Update Prices" CssClass="fieldlabel" />
                <asp:FileUpload ID="importFileUpload" runat="server" />

我需要添加一个必填字段验证器才能接受.csv文件。我该怎么做?

谢谢!

1 个答案:

答案 0 :(得分:0)

<asp:RegularExpressionValidator ID="uplValidator" runat="server" ControlToValidate="importFileUpload" ErrorMessage="Only .csv files are allowed" 
                            ValidationExpression="(.+\.([Cc][Ss][Vv]))" />

添加了此REV以使其正常工作!