I have a page where users can add attachments to emails. When they click to start uploading their attachments, I run a bit of javascript to set a label to read (for example) 'Uploading File 1 of 4'
The code that handles the upload is below. As each file is saved, I want to update the browser label to read (for example) 'File 1 uploaded. Uploading File 2 of 4'. Etc.
What technique can I use to keep the browser notified as the files are updated? I don't need a progress bar.
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(path + ReturnValue.ToString() + "\\" + Path.GetFileName(hpf.FileName));
//This is where I want to update the browser so the user is informed as each file is uploaded
}
}
I tried using Response.Write to write <script type="text/javascript">alert('File 1 uploaded')</script>
just to see if that would do anything. But it does not work.
I tried using ScriptManager.RegisterStartUpScript
to call a function but that didn't work.