|
Rank: Newbie Groups: Member
Joined: 11/9/2010 Posts: 4
|
The following code have a textbox1 where must be input the description of the file that will be uploaded and one ajaxuploader control. There is a java script function that validate the textbox1 (it cannot be leaved empty). But the following code does not work. I aspect that the file will be uploaded in the temp dir, but ajaxuploader save only a status file of 1k in temp dir. Can someone tell me why ? Quote: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" inherits="_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> <script language="javascript" type="text/javascript"> function CustomErrorHandler(control, error, message) { if (error == "max_size_exceeded") { alert("The File size exceeded the max size allowed."); } if (error == "extension_not_allowed") { alert("This type of File is not allowed."); } } function StartUpload() { var uploader = eo_GetObject("AJAXUploader1"); var textbox = document.getElementById("<%= TextBox1.ID %>"); if (textbox.value) { uploader.upload(); } else { alert('Please insert the description of File.'); } } </script> </head> <body> <form id="form1" runat="server"> <div> <table cellpadding="0" cellspacing="0" style="width:100%"> <tr> <td><asp:TextBox ID="TextBox1" runat="server" Width="250px"></asp:TextBox></td> </tr> <tr> <td> <eo:AJAXUploader ID="AJAXUploader1" runat="server" Width="250px" TempFileLocation="~/public/temp" ClientSideOnError="CustomErrorHandler" AllowedExtension=".jpg" MaxDataSize="500"> <LayoutTemplate> <table border="0" cellpadding="2" cellspacing="0" width="250px"> <tr> <td><asp:PlaceHolder runat="server" id="InputPlaceHolder">Input Box Place Holder</asp:PlaceHolder></td> </tr> <tr> <td align="right"><asp:Button runat="server" ID="UploadButton" Text="Upload" style="display:none" /></td> </tr> <tr> <td><eo:ProgressBar runat="server" id="ProgressBar" ControlSkinID="Windows_XP" /></td> </tr> <tr> <td><asp:PlaceHolder runat="server" id="ProgressTextPlaceHolder">Progress Text Place Holder</asp:PlaceHolder></td> </tr> <tr> <td align="right"><asp:Button runat="server" ID="CancelButton" Text="Cancel" /></td> </tr> <tr> <td><asp:PlaceHolder runat="server" id="PostedFilesPlaceHolder">Posted Files Place Holder</asp:PlaceHolder></td> </tr> <tr> <td align="right"><asp:Button runat="server" ID="DeleteButton" Text="Delete Selected Files" /></td> </tr> </table> </LayoutTemplate> </eo:AJAXUploader> </td> </tr> <tr> <td><asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="StartUpload();" /></td> </tr> </table> </div> </form> </body> </html>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Your code looks fine to us. You can try to handle the Uploader's FileUploaded event and see if it fires. Note that FileUploaded event is not fired until the page posts back. You can either post back with a separate button, or set the uploader's AutoPostBack to true so that it causes a post back as soon as the upload is done. Post back is not the same as starting upload. The sequence is: user chooses a file -> start upload -> transfering file -> post back -> FileUploaded event.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/9/2010 Posts: 4
|
Uploader's FileUploaded event is not fired (infact also progress bar does not start) and the uploader autopostback property is set to true. The only file that i find in temp dir is a status file with this hex content: FFFF FFFF FDFF FFFF 01. I test it with Visual Web Developers 2010 express (.net 2.0 project) and XP with IIS6.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We do not know what can cause that. Please try to run our sample page and see if the same project occurs.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 11/9/2010 Posts: 4
|
I see that the "uploader.upload()" method inside the javascript function works only if called by an onclick event from html object like a button tagged <input>. The code does NOT work if the button is an asp button tagged <asp:button>. Infact in your example you have used an html buttom object tagged <input>. Did you have an answer for that ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That makes perfect sense ---- you should use an <input> tag, not asp:Button. By default asp:Button causes a post back when you click it. So right after you click the button, the upload started, but then your page is immediately posted back.
The normal sequence is start upload --> transfer file --> post back. Post back should only occur after the file has been transferred.
Thanks!
|
|