<asp:FileUpload ID="fuSignature" runat="server" />
<asp:RegularExpressionValidator ID="RegExValFileUploadFileType" runat="server"
ControlToValidate="fuSignature"
ErrorMessage="Only .jpg,.png,.jpeg,.pdf files are allowed" ForeColor="Red"
Font-Size="Medium"
ValidationExpression="(.*?)\.(jpg|jpeg|png|pdf|JPG|JPEG|PNG|PDF)$"></asp:RegularExpressionValidator>
OR
protected void BtnSave_Click(object sender, EventArgs e)
{
if (fuSignature.HasFile)
{
string fileExtension =
System.IO.Path.GetExtension(fuSignature.FileName);
if (fileExtension.ToLower() == ".jpeg" || fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".pdf")
{
// do ur work like save file
}
else
{
lblMeaasge.Text = "Only .jpeg,.jpg,.pdf file allow";
}
}
else
{
lblMeaasge.Text = "Please Upload File";
}
}
<asp:RegularExpressionValidator ID="RegExValFileUploadFileType" runat="server"
ControlToValidate="fuSignature"
ErrorMessage="Only .jpg,.png,.jpeg,.pdf files are allowed" ForeColor="Red"
Font-Size="Medium"
ValidationExpression="(.*?)\.(jpg|jpeg|png|pdf|JPG|JPEG|PNG|PDF)$"></asp:RegularExpressionValidator>
OR
protected void BtnSave_Click(object sender, EventArgs e)
{
if (fuSignature.HasFile)
{
string fileExtension =
System.IO.Path.GetExtension(fuSignature.FileName);
if (fileExtension.ToLower() == ".jpeg" || fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".pdf")
{
// do ur work like save file
}
else
{
lblMeaasge.Text = "Only .jpeg,.jpg,.pdf file allow";
}
}
else
{
lblMeaasge.Text = "Please Upload File";
}
}
No comments:
Post a Comment