protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
if (fileExt == ".jpg" || fileExt == ".png" || fileExt == ".gif" || fileExt == ".jpeg")
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientscript", "alert('File Size must be less than 200 Kb!')", true);
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please choose only .jpg, .png and .gif image types!')", true);
function uploadError(sender, args) {
try {
$get("dvFileErrorInfo").style.display = 'block';
$get("dvFileInfo").style.display = 'none';
$get("<%=lblError.ClientID %>").innerHTML = "File not uploaded" + args.get_errorMessage();
}
catch (e) {
}
}
function uploadComplete(sender, args) {
try {
var fileExtension = args.get_fileName();
var gif =fileExtension.indexOf('.gif');
var png =fileExtension.indexOf('.png');
var jpg=fileExtension.indexOf('.jpg');
var jpeg=fileExtension.indexOf('.jpeg');
if (gif > 0 || png > 0 || jpg > 0 || jpeg > 0)
{
if (fileExtension.indexOf('.doc') != -1) {
$get("dvFileErrorInfo").style.display = 'block';
$get('<%=lblError.ClientID %>').innerHTML = "File extension not supported";
$get("dvFileInfo").style.display = 'none';
return;
}
if (parseInt(args.get_length()) > 204800) {
$get("dvFileErrorInfo").style.display = 'block';
$get('<%=lblError.ClientID %>').innerHTML = "File size should nto be greater than 200 kb";
$get("dvFileInfo").style.display = 'none';
return;
}
$get("dvFileErrorInfo").style.display = 'none';
$get("dvFileInfo").style.display = 'block';
$get('<%=lblSuccess.ClientID %>').innerHTML = "File uploaded successfully !!!";
}
else
{
$get("dvFileErrorInfo").style.display = 'block';
$get("<%=lblError.ClientID%>").innerHTML = "Allowed File extension are {.gif,.png,.jpg,.jpeg} supported";
$get("dvFileInfo").style.display = 'none';
return;
}