if you want to validate from the client side use the following:
function ValidatePDFupload(Source, flag)
{
var pathTextBox = document.getElementById('txtBoxFilePath');
var FileUploadPath = pathTextBox.value;
var FileExtension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();
if (FileExtension == "pdf")
{
flag.IsValid = true;
}
else
{
flag.IsValid = false;
}
}
if you want to validate from the server side, use the following:
string p = @"C:\Users\linton\Documents\Sample.pdf";
string e = Path.GetExtension(p);
if (e == ".pdf")
{
Console.WriteLine(e);
}