I used the following code for implementing a file upload progress indicator, using UpdateProgress Panel, though I have a problem that FileUpload.Has File always returns false. Any suggestions what might be wrong?
FileUpload2.asp x
<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="FileU pload2.aspx.cs" Inherits="FileU pload2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title> drag </title>
</head>
<body>
<form id="f1" enctype="multip art/form-data" runat="server">
<h4>Select a file to upload:</h4>
<atlas:ScriptMa nager ID="ScriptManag er1" runat="server" EnablePartialRe ndering="true" />
<atlas:UpdatePa nel ID="upResults" runat="server" Mode="condition al">
<Triggers>
<atlas:ControlE ventTrigger ControlID="Uplo ad" EventName="Clic k" />
</Triggers>
<ContentTemplat e>
</ContentTemplate >
</atlas:UpdatePan el>
<asp:FileUplo ad id="FileUpload " runat="server"> </asp:FileUpload>
<br /><br />
<asp:Button id="Upload" Text="Upload file" OnClick="Upload Button_Click" runat="server">
</asp:Button>
<atlas:UpdatePr ogress ID="uprProgress " runat="server">
<ProgressTempla te>
<img src="images/animated_loadin g.gif" /> Uploading....
</ProgressTemplat e>
</atlas:UpdatePro gress>
</form>
</body>
</html>
FileUpload2.asp x.cs
using .....;
public partial class FileUpload2 : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected void UploadButton_Cl ick(object sender, EventArgs e)
{
// Specify the path on the server to save the uploaded file to.
String savePath = @"C:\Temp\uploa ds\";
// Before attempting to perform operations on the file, verify that the FileUpload control contains a file.
if (FileUpload.Has File)
{
String fileName = FileUpload.File Name;
savePath += fileName;
// Call the SaveAs method to save the uploaded file to the specified path.
FileUpload.Save As(savePath);
// Notify the user of the name of the file was saved under.
// UploadStatusLab el.Text = "Your file was saved as " + fileName;
}
else
{
// Notify the user that a file was not uploaded.
// UploadStatusLab el.Text = "You did not specify a file to upload.";
}
}
}
Any suggestions what might be wrong?
Thanks,
Marko Vuksanovic.
"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com> wrote in message news:ee******** ******@TK2MSFTN GP02.phx.gbl...
this will be tricker than you may think. ajax progress bars work by polling the server for status of the operation. to poll the status of an upload you need to poll the server for how far along it is. there are a couple issues
1) as IIS streams the request to asp.net, asp.net does not give a handy way to get the request stream in progress. you will proably have to write an isapi filter to get the number of bytes transfered.
2) the client may not send the size of the file, so the server will not know how big it is to calc how far along the transfer is.
3) while the request (upload) is in progress, the browser may not allow the ajax code to make another request.
-- bruce (sqlwork.com)
"John Timney (MVP)" <x_****@timney. eclipse.co.uk> wrote in message news:Hu******** *************** *******@eclipse .net.uk...
if you do a google search for Ajax progress bar you'll find lots of examples, like this one.
http://www.wilcob.com/Wilco/Default/159/showpost.aspx
-
Regards
John Timney (MVP)
"Marko Vuksanovic" <ma************ *@hotmail.com> wrote in message news:B2******** *************** ***********@mic rosoft.com...
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is it possible to implement it using some other control, for example a floating window?