code:
<span>Upload Adobe Acrobat file<img src="../../Images/UI/pdf.jpg" style="height: 25;
width: 20" height="25" width="20" /></span>
<asp:FileUpload ID="uplPdf" runat="server" />
<asp:RegularExpressionValidator ID="valPdf" runat="server" ErrorMessage="Only PDF files are allowed!"
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.pdf)$" Display="Dynamic"
ControlToValidate="uplPdf" ValidationGroup="upload" />
<br />
<asp:Button ID="btnUpload" runat="server" Text="Upload files" OnClick="btnUpload_Click"
ValidationGroup="upload" />
code behind:
if (valPdf.IsValid && uplPdf.HasFile)
IsValid returns false after a valid pdf file name was enterd. Note that if no file is specified, returns true.