473,473 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with FileUpload control and doPostback

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
1 7020
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roz Lee | last post by:
I have a page with two textboxes and two buttons which post back to the server. I want to detect which button has been clicked for testing purposes preferably clientside, but otherwise serverside....
2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
4
by: Dave | last post by:
If you had a FileUpload control inside of a FormView...how would you use FindControl to access the FileUpload properties? Let me just say that...
3
by: rn5a | last post by:
The ASPX FileUpload control displays a TextBox along with a 'Browse...' Button. Setting the different properties of this control just reflects the changes in the TextBox but not the Button. For...
3
by: s9213037 | last post by:
Use case scenario: I have a panel with ID "Upload_Panel", where there is a FileUpload control with ID "FileUpload1" and a button with ID "More_Upload_Files", both of which are added at design...
5
by: =?Utf-8?B?QmVydA==?= | last post by:
Hi How can you set the filename property in the asp:fileupload control? How can you persist the value of the chosen filename between postbacks? thanks B
9
by: vital | last post by:
Hi, I have a User control which has a fileupload control. With the requirements I placed the user control in a UpdatePanel of ASP.NET Ajax and the fileupload.postedfile.filename giving error. ...
4
by: pechar | last post by:
Hi All, This question has been asked many times and I've checked most of the sites with resolutions. None worked for me. 1) I have a page which is a content page to a Masterpage . 2) I have a...
4
by: JFKJr | last post by:
Hello Guys, I have been trying to solve the following problem from past 3 days with no luck. This is what I am trying to do: I want to allow user (Professor) to choose a course material...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.