Welcome Guest Search | Active Topics | Sign In | Register

AjaxUploader PostedFile Empty 8.0.56.2 Options
Jim
Posted: Monday, July 25, 2011 3:02:11 PM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
Hi,

I have serveral AjaxUploader controls in a usercontrol and the usercontrol loads dynamically. If I have a validation error on the page, my file uploads are empty when the page finishes rendering. I can see the filename on the rendered page, but the delete button is gone and if I tried to save the files to the database, the postedfiles is empty. If I post the page twice with the validation error, the second time the page displays without any files having been uploaded. Ideas?

Thanks in advance.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="EOUploaderTest._default" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<eo:AJAXUploader ID="AJAXUploader1" runat="server" Width="250px" AutoUpload="True" FinalFileLocation="~/Upload" ViewStateMode="Enabled" TempFileLocation="~/Upload" FinalFileList="AJAXPostedFileList1">
</eo:AJAXUploader>
<eo:AJAXPostedFileList ID="AJAXPostedFileList1" runat="server">
</eo:AJAXPostedFileList>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="False" />
</form>

</body>
</html>


In this sample, click the button1 twice.
eo_support
Posted: Monday, July 25, 2011 4:35:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The code you posted is normal. The problem that you are having almost certainly has to do with your dynamic loading code. The general rule about dynamic loading is that you must recreate the same control at exactly the same place in your control tree when the page posts back at the early stage of the page. Otherwise all kind of strange problems can happen. This post explained the problem in greater detail:

http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1056

The post is for the CallbackPanel control. However it's a general ASP.NET rule so it applies to any controls.

Thanks!
Jim
Posted: Monday, July 25, 2011 4:37:55 PM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
Hi,

The code I posted will result in an empty list and it's not dynamic. Your control isn't holding the session state info. Ideas?

Thanks,

Wayne
eo_support
Posted: Tuesday, July 26, 2011 7:36:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We tested the code on the latest version and it works fine. Once you upload one file, AJAXPostedFileList will have one item (AJAXPostedFileList.Items.Length is 1). If you wish AJAXPostedFileList to keep multiple items, you must set the AJAXUploader's SavePostedFileList to true.

Note that AJAXPostedFileList does not really render anything. So you can only see whether it's empty or not with your debugger. It's similar to a DataSource control. You will need to use another control to display its content.

Thanks
Jim
Posted: Tuesday, July 26, 2011 8:19:48 AM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
Hi,

I need the ajaxuploader to keep the file contents and inforamtion as well as functionality. After a postback, the abiliy to delete the item is gone. The button is disabled. In the code above, the SavePostedFileList is set to true, as this is the default value. Sorry, but your code isn't working correctly. The ajaxuploader has the enableviewstate so it should retain the file contents on postback, which it isn't. This is why I purchased your controls in the first place. So, how does the user delete a file after a postback has occured? In the example above, it's gone and I have he properties set correctly, per your post.

Thanks
Jim
Posted: Tuesday, July 26, 2011 8:26:04 AM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
I see there is a version 2011. Downloading it now, maybe this is an old bug.
Jim
Posted: Tuesday, July 26, 2011 9:00:55 AM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
Here is the latest code with the latest version from your website 9.0.15.2. If I click the button twice, the AjaxUploader control has no posted files.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="EOUploaderTest._default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="False" />

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<eo:AJAXUploader ID="AJAXUploader1" runat="server" AutoUpload="True"
FinalFileList="AJAXPostedFileList1" FinalFileLocation="~/Upload"
TempFileLocation="~/Upload" ViewStateMode="Enabled" Width="250px">
</eo:AJAXUploader>
<eo:AJAXPostedFileList ID="AJAXPostedFileList1" runat="server">
</eo:AJAXPostedFileList>
</form>





</body>
</html>
eo_support
Posted: Tuesday, July 26, 2011 9:34:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

I believe this is how to suppose to work. There are two different file lists:

1. Temp file list. This list is associated to TempFileLocation and is managed by the AJAXUploader. The AJAXUploader can only delete files from temp file list;

2. Final file list. This list is associated to FinalFileLocation and is managed by AJAXPostedFileList. This control keeps the file list but has no UI for it;

When you upload a file, it first appears in the temp file list, then the AJAXUploader’s FileUploaded is fired, then it is moved to the final file list. You can upload multiple files without posting back the page (without clicking Button1 in your case). As soon as the page is not posted back, FileUploaded event is not fired and all the uploaded files stay in the temp file list. When they are in the temp file list, you can delete any of them with the uploader’s delete button. There are two principles behind this design:

1. You can modify your input ONLY before you “hand it over”. Once you submit the page, you “hand over” the temp files off to your application (or another component in this case AJAXPostedFileList). From that moment on, you (the uploader) can no longer modify it;

2. The “hand over” event (in this FileUploaded event) only occurs only once for the same file. This is necessary to avoid people from “processing” the same file more than twice. For example, some user choose to save the uploaded files to database. In that case if we fire FileUploaded event more than once for the same file, then they will have duplicate records in their db;

What you want to do basically depends on which list you wish to work with. If you wish to work with the temp file list, then you don’t have to do anything. If you wish to work with the final file list, then you use a AJAXPostedFileList as you did and then code the UI to work with that list. This sample have the full source code on how to do this:

http://demo.essentialobjects.com/Demos/AJAX%20Uploader/File%20List/Demo.aspx

Hope this clears up.

Thanks
Jim
Posted: Tuesday, July 26, 2011 1:25:54 PM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
So I tried the demo as you indicated in my sample code. If I go to your demo (http://demo.essentialobjects.com/Demos/AJAX%20Uploader/File%20List/Demo.aspx), please perform the following steps.

1. Click browse and select file.
2. Click upload.
3. Click Submit. (notice your file from step #2 is still in the temp location, without the delete button). If you were not using java script to disable the submit button, I could click the submit twice and my file would be gone. If this where a text box, I would still have my information in the view state. It is in the table, but that should demo the use of your AjaxPostedFileList control, not the Ajaxuploader. The Ajaxupload should contain all uploaded files in the temp file location until we (the programmer) decides to empty it, not just because a simple post back has occured. You should be holding the data and rebinding it. Sorry, but I really think your control has a bug. Otherwise, what is the point of purchasing your control set? The point of custom controls like this is to retain the file list without me having to write lots of extra code.

eo_support
Posted: Tuesday, July 26, 2011 1:47:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Thanks for your feedback. However we do not believe this is a bug. We have already explained quite thoroughly how it works in our previous post. The list is properly maintained by the AJAXPostedFileList control.

We would certainly disagree with you about "the point of custom controls is to retain the file list". The main feature of the uploader is to give you the ability to "AJAX upload" a file. The most notable difference is it can upload a file and give you progress information. Another main benefit is it can upload huge files without saving the whole file in memory (the standard ASP.NET file upload saves the whole file in memory thus would cause out of memory error for big files). Those are what AJAX uploader is really about. It is not about keeping files --- some users want to keep the files, most users do not. Even though the uploader does offers some assistance to you on this --- a delete button to the temp list and an additional AJAXPostedFileList for you to maintain the permanent list.

Your best option is to take the sample code we posted in our previous reply and adapt it to fit your need. Our uploader has been on the market for many years. A lot of users are using it. So we can’t just change how it works because it doesn’t work exactly the way you wanted. If we change it, other users would wanted us to change it back, not to mention that we neither believe it’s a bug nor believe any change is necessary because the AJAXPostedFileList does have the full list you needed.

This issue is now closed.

Thanks
Jim
Posted: Tuesday, July 26, 2011 1:53:48 PM
Rank: Member
Groups: Member

Joined: 1/16/2009
Posts: 22
Can you please explain why your demo still has the file name in the control and in the datagrid on your demo page? Did you even try the steps I outlined in the previous post.
eo_support
Posted: Tuesday, July 26, 2011 2:19:41 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We don't have to try. The behavior you observed is the expected behavior and is consistent with behavior you described in your previous post.

The DataGrid is used to display the final file list ---- the list maintained by the AJAXPostedFileList. So the file should be in that list.

The file in the control is the temp file list ---- the last temp file list is displayed back to you ONCE after the post back. However even if it is displayed back to you, the underlying file has actually been moved (to the final file location), so you won’t be able to delete any of them --- as you will notice that the delete button is no longer there.

As we have mentioned previously, if you wish to work with the final file list, you should rely on the AJAXPostedFileList control. That’s the route we put in place for such cases. Usually if you work with the final file list, you will also wish to turn off the AJAXUploader’s built-in temp file list completely because obviously you do not want your user to be confused with two lists. You can do that with a custom LayoutTemplate on the uploader control.

Hope this answers your question. If you are still pondering the AJAXUploader’s temp file list, then you are really focusing on the wrong place. I do not see any reason or possibility that we would extend that to cover the final file list. Doing so would run the risk of breaking backwards compatibility with our existing user for a completely unnecessary “feature” since it’s already been covered by the AJAXPostedFileList control. That’s why we cannot do that.

I believe this post and all our previous reply have already thoroughly explained this matter. As such we will no longer reply this thread on this topic. If you have a different question, please start a new thread.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.