Problem with FileUpload control and doPostback


Marko Vuksanovic

I am trying to implement an upload progress indicator using atlas, using the following workaround:

This is the code in FileUpload.apsx file is as follows:
<html xmlns="" >
<head id="Head1" runat="server">
<title> drag </title>
<form id="f1" enctype="multipart/form-data" runat="server">
<h4>Select a file to upload:</h4>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />

<atlas:UpdatePanel ID="upResults" runat="server" Mode="conditional">
<atlas:ControlEventTrigger ControlID="Upload" EventName="Click" />
<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"> </asp:Button>

<asp:Button id="Button1" OnClick="UploadButton_Click" runat="server"></asp:Button>
<br /><br />
<atlas:UpdateProgress ID="uprProgress" runat="server">
<img src="images/animated_loading.gif" /> Uploading....


The relevant code from the code behind file is:

protected void Page_Load(object sender, EventArgs e)
Upload.Attributes.Add("onClick", "__doPostBack('" + Button1.ClientID + "','');return false;");
ClientScript.GetPostBackEventReference(Button1, "");

protected void UploadButton_Click(object sender, EventArgs e)
String savePath = @"C:\Temp\uploads\";
if (this.FileUpload.HasFile)
String fileName = FileUpload.FileName;
savePath += fileName;

The problem is, in the line of code in the Page_Load Function, if I use the "onClick" the (ProgressTemplate is not displayed), if I use the "onClientClick" the ProgressTemplate is correctly displayed but the file is not uploaded.

Any help is greatly appreciated.

Many thanks,

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question