Click here to Skip to main content
15,850,360 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am new to this discussion board.
I have a problem with progressbar for multiple file upload. I have developed a multiple file uploader using treeview. now i need to show the progress of the upload, for which i need to call a javascript function from server side function which does the upload ( I tried RegisterClientScriptBlock but didn't work) and this function should update the progress bar while the upload process is being done on backend

please help me by giving some idea of how this can be solved?

Thanks,
NM
Posted
Updated 7-Jun-10 21:25pm
v3

1 solution

I found a good solution in one of the codeproject blogs itself
http://www.aspnettutorials.com/tutorials/themes/progress-bar-csharp.aspx

it actually is using a threading for the file upload process but the problem was that it is not updating the page with final results like time taken for the upload process

for my requirement i placed the progressbar.aspx page in an Iframe on my Upload page and tried to call a function in Progressbar.aspx page which inturn will call window.submit using javascript that is updating the progress time to time

also to calculate the percentage of upload done we took the size of all the files and calculated the percentage of current file size in the whole size

to stop the thread and update the page this is the code we added

catch (Exception ex)
{
LogText("Exception : " + ex.Message);
if (ex.InnerException != null) LogText("Inner Exception : " + ex.InnerException.Message);
LogListToSession();
Session["State"] = 100;
Page.RegisterClientScriptBlock("", "<script>window.close('Progress.aspx');</script>");
}</pre>

this is to open the progressbar

public static void OpenProgressBar(System.Web.UI.Page Page)
{
try
{
ProgressBar_C_.Progress Prgbar = new ProgressBar_C_.Progress();
Prgbar.CallProgress();
}
catch (Exception ex)
{
}

to get length of all the files selected to upload


protected void GetLengthofAllFiles(string[] filesToBeUploaded)
{
foreach (string file in filesToBeUploaded)
{
//get and add the file length to totalLength
System.IO.FileInfo fileInfo = new System.IO.FileInfo(file);
totalLength = totalLength + fileInfo.Length;
}

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900