我希望用户使用FileUpload上传4张照片,如果其中任何一张为空,我想显示错误消息。如何验证所有这些都已正确填充?
<div id="upload-area">
<div id="photo1">
<asp:FileUpload ID="PhotoUpload1" CssClass="photo-upload" ValidationGroup="PhotoUpload" runat="server" size="38" />
</div>
<div id="photo2">
<asp:FileUpload ID="PhotoUpload2" CssClass="photo-upload" ValidationGroup="PhotoUpload" runat="server" size="38" />
</div>
<div id="photo3">
<asp:FileUpload ID="PhotoUpload3" CssClass="photo-upload" ValidationGroup="PhotoUpload" runat="server" size="38" />
</div>
<div id="photo4">
<asp:FileUpload ID="PhotoUpload4" CssClass="photo-upload" ValidationGroup="PhotoUpload" runat="server" size="38" />
</div>
</div>
ASP.NET验证程序
<div id="upload-warning">
<asp:RequiredFieldValidator ID="PhotoUploadValidator" runat="server"
ControlToValidate="PhotoUpload1" CssClass="upload-warning">
<img src="image/mobile/exclamation-mark.png" />
<span style="vertical-align: middle;">请上传四幅作品,您还需上传一幅作品。</span>
</asp:RequiredFieldValidator>
</div>
感谢。