I have a webform that uploads a digital sound file to my web server. I would like to show a progress bar or an animated gif to keep the user entertained while they are waiting. I have tried a number of ways to achieve this (I am new to web programming!),
The upload works great but the animated gif only works once the file upload has completed, no matter where I insert it in the code. Any help on this will be very much appreciated.
Code Below (Panelupload contains the animated gif!)
Sub Upload_Click(Sender as Object, e as EventArgs)
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim c as string = System.IO.Path.GetFileName(strFileName) ' only the attched file name not its path
Try
MyFile.PostedFile.SaveAs("D:\mydomain.co.uk\NewFiles\" + c)
Span1.InnerHtml = "Your File Uploaded Sucessfully. "
catch Exp as exception
span1.InnerHtml = "An Error occured. Please check the attached file"
UploadDetails.visible = false
span2.visible=false
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
dtanner2k@ho...
0 Points
1 Post
Progress Bar on File Upload ASP.NET
May 06, 2007 09:21 PM|LINK
Hello,
I have a webform that uploads a digital sound file to my web server. I would like to show a progress bar or an animated gif to keep the user entertained while they are waiting. I have tried a number of ways to achieve this (I am new to web programming!), The upload works great but the animated gif only works once the file upload has completed, no matter where I insert it in the code. Any help on this will be very much appreciated.
Code Below (Panelupload contains the animated gif!)
Sub Upload_Click(Sender as Object, e as EventArgs)
panelupload.visible = true
' Display properties of the uploaded file
FileName.InnerHtml = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
UploadDetails.visible = True
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim c as string = System.IO.Path.GetFileName(strFileName) ' only the attched file name not its path
Try
MyFile.PostedFile.SaveAs("D:\mydomain.co.uk\NewFiles\" + c)
Span1.InnerHtml = "Your File Uploaded Sucessfully. "
catch Exp as exception
span1.InnerHtml = "An Error occured. Please check the attached file"
UploadDetails.visible = false
span2.visible=false
End Try
End Sub
Thanks
Haissam
All-Star
37421 Points
5632 Posts
Re: Progress Bar on File Upload ASP.NET
May 07, 2007 06:15 AM|LINK
Check below link
FileUpload with progressbar asp.net
HC
MCAD.NET
| Blog |
Jessica Cao ...
All-Star
25328 Points
2567 Posts
Re: Progress Bar on File Upload ASP.NET
May 08, 2007 01:50 AM|LINK
Hello,
My suggestion is using Ajax UpdateProgress Control, here is code sample
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UploadImageWithAjax.aspx.cs" Inherits="UploadImageWithAjax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:FileUpload ID="FileUpload1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="indicator_mozilla_blu.gif" /><br />
uploading.............
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>
public partial class UploadImageWithAjax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
FileUpload1.SaveAs(Server.MapPath("~/" + FileUpload1.FileName));
}
}
Hope it helps,
Jessica
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Jessica Cao ...
All-Star
25328 Points
2567 Posts
Re: Progress Bar on File Upload ASP.NET
May 10, 2007 08:19 AM|LINK
Hello,
As for how to use Ajax, see these tutorials
http://ajax.asp.net/default.aspx?tabid=47
http://www.asp.net/learn/videos/view.aspx?tabid=63&id=123
Hope it helps,
Jessica
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
M A A Mehedi...
Contributor
7324 Points
939 Posts
Re: Progress Bar on File Upload ASP.NET
May 10, 2007 08:43 AM|LINK
Hello,
Take a look here.
http://www.codeproject.com/useritems/UpldFileToDiskProgressBar.asp
http://www.codeproject.com/aspnet/FlashUpload.asp
Mark as answer if the post meets your requirement!
waqar-ahmad
Member
17 Points
8 Posts
Re: Progress Bar on File Upload ASP.NET
Sep 16, 2010 06:36 AM|LINK
check this out.
http://waqarahmadbhatti.blogspot.com/2010/09/uploading-file-with-progress-bar-in.html
Waqar Sher Bhatti
http://waqarsherbhatti.posterous.com/