By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Problem with FileUpload control and doPostback

P: n/a
I am trying to implement an upload progress indicator using atlas, using the following workaround:
http://forums.asp.net/thread/1321664.aspx

This is the code in FileUpload.apsx file is as follows:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title> drag </title>
</head>
<body>
<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">
<Triggers>
<atlas:ControlEventTrigger ControlID="Upload" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"> </asp:Button>
</ContentTemplate>
</atlas:UpdatePanel>

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

</form>
</body>
</html>

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;
FileUpload.SaveAs(savePath);
}
else
{
}
}

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,
Marko

Jun 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Upload control dosent work with atlas :)

"Marko Vuksanovic" wrote:
I am trying to implement an upload progress indicator using atlas, using
the following workaround:
http://forums.asp.net/thread/1321664.aspx

This is the code in FileUpload.apsx file is as follows:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<titledrag </title>
</head>
<body>
<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">
<Triggers>
<atlas:ControlEventTrigger ControlID="Upload" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:FileUpload id="FileUpload" runat="server"</asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server">
</asp:Button>
</ContentTemplate>
</atlas:UpdatePanel>

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

</form>
</body>
</html>

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;
FileUpload.SaveAs(savePath);
}
else
{
}
}

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,
Marko
Jul 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.