Show Loading (Progress) Image when uploading files using JavaScript in ASP.Net

Last Reply one month ago By pandeyism

Posted one month ago

hello,

i am using following code to upload image i need to show gif while uploading image

        <asp:FileUpload ID="fileUpload" runat="server" />
        <asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="UploadmultiMethod" Style="display: none" />
        <script type="text/javascript">
            function UploadFile(fileUpload) {
                if (fileUpload.value != '') {
                    document.getElementById("<%=btnUpload.ClientID %>").click();
                }
            }
        </script> 

 

protected void Page_Load(object sender, EventArgs e)
{
    fileUpload.Attributes["onchange"] = "UploadFile(this)";
    //Image img = (Image)this.UploadImage.FindControl("Image1");
}

 

        protected void UploadmultiMethod(object sender, EventArgs e)
        {
            if (fileUpload.HasFile)
            {
                if (fileUpload.PostedFile.ContentLength < 15728640)
                {
                    CheckFile image = new CheckFile();
                    //Image1.ImageUrl = image.UploadImages(FileUpload1Multi);

                    ProjectFile pf = new ProjectFile();

                    pf.ProjectFiles = image.UploadImages(fileUpload);
                    pf.ProjectGUID = Guid.Parse(Request.QueryString["ID"].ToString());
                    pf.ProjectFileName = TextBox1.Text;

                    db.ProjectFiles.Add(pf);
                    db.SaveChanges();
                    imagebindinglist();
                }

                else
                {
                    lblerror.Text = "Size should be less than 15 MB.";
                }
            }
        }

 

You are viewing reply posted by: pandeyism one month ago.