<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.Master"
CodeBehind="Mortgageclient.aspx.cs" Inherits="MortgageSaver._Default" %>
protected void btnfupload_Click(object sender, EventArgs e)
{
try
{
if (FileUpload1.HasFile)
{
if (!Directory.Exists(Server.MapPath("Documents")))
{
Directory.CreateDirectory(MapPath("Documents"));
}
string docment = FileUpload1.PostedFile.FileName;
string path = System.IO.Path.GetFileName(docment);
FileUpload1.PostedFile.SaveAs(Server.MapPath("Documents/") + path);
lblstatus.ForeColor = System.Drawing.Color.Red;
lblstatus.Text = "Selected File has been Uploaded...";
}
}
catch
{
lblstatus.ForeColor = System.Drawing.Color.Red;
lblstatus.Text = "Selected File has not been Uploaded...";
}
}
This is my code to upload a file,but it selecting a file from dialogue box but when i click the UploadFile button it displaying “Selected File has not been Uploaded.”and if i could run this page individually i is working,but i’m using it in tabpanel as above,so in this case it is not working.
FileUpload control cannot be used with asynchronous postbacks. see this page, scroll all the way down to “Using Web Parts Controls Inside UpdatePanel Controls” section. Alternative solution is “AsyncFileUpload” from Ajax tool kit.