Ajax Uploader - ManualStartUpload="true"

Last post 06-17-2011, 12:59 AM by Kenneth. 9 replies.
Sort Posts: Previous Next
  •  06-13-2011, 3:14 PM 67933

    Ajax Uploader - ManualStartUpload="true"

    Hello,
     
    I am using an Ajax uploader control with ManualStartUpload="true".  My problem is that on the same page, I am doing a lot of Jquery Ajax calls to populate various parts of the page. So the main page has several parts that get their HTML and data by making Jquery AJAX calls.  While I can use the Ajax uploader control to browse for and select files, on my Submit click, I need to also do the upload in client side with out going back to the server side code.  when I try to do this, I get the following error message:
     
    'the State information is invalid for this page and might be corrupted'  
     
    In my client side function when the submit button is clicked, I am finding the uploader object and calling uploader.startupload() on it.  The upload begins, and the indicator goes from 0% to 100% and turns green, but the above error message also shows up and there is a little warning icon next to the file that I tried to upload.  When I hover over the alert icon, the tool tip says cancelled.  Do you have any suggestions/ideas?
     
    Regards. 
     
     
  •  06-14-2011, 1:34 AM 67945 in reply to 67933

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi mchamo,
     
    Please set the below setting in your web.config file and try again.
     
    <pages enableEventValidation="false" viewStateEncryptionMode ="Never" /> 
     
    If it has not fix this issue, please create an example which can reprduc this issue and send it to Kenneth@CuteSoft.net. I will check it and get back to you as soon as possible.
     
    Please include all necessary files in the example, so I can check it directly.
    Regards,
     
    Ken
  •  06-14-2011, 7:39 AM 67949 in reply to 67945

    Re: Ajax Uploader - ManualStartUpload="true"

    Thanks Ken, that worked.  In fact, I only had to set this:
     
    <pages enableEventValidation="false"> 
     
    I am pretty new to the Ajax Uploader control, so now that it uploads, I am trying to figure out where it uploads to, and how I can alter the location/directory of where the control uploads to?  Is there a setting that I can control to indicate to the Ajax Uploader control the path that uploaded files should be uploaded to?
     
    To elaborate further, I need to be able to set where the files get uploaded to (on a server in the network) and also, I need to also be able to control the names of the files (i.e a user may upload file01.pdf, but I will have to save it with a different name for example a CaseID + DateStamp).  The CaseID is a value that I already have in my app.
     
    Regards. 
  •  06-14-2011, 12:03 PM 67958 in reply to 67949

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi mchamo,
     
    Please refer to http://cutesoft.net/forums/thread/65579.aspx , the highlighted code set the destination folder.
     
     void Uploader_FileUploaded(object sender, UploaderEventArgs args)
    {
    //Copys the uploaded file to a new location.
    args.CopyTo("c:\\temp\\"+args.FileName);
    //You can also open the uploaded file's data stream.
    //System.IO.Stream data = args.OpenStream();
    }
    You can write customization code and change "c:\\temp\\"+args.FileName to the actual file name based on your requirement.
     
    Thanks for asking
  •  06-14-2011, 2:16 PM 67960 in reply to 67958

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi Eric, is there anyway to achieve this using client side code without going back to the server?  Or is there anyway to perform client side code on the file uploaded event?  Basically, I don't want the fileuploaded event to cause a postback.  for example, for an asp button, I can do the following code on load, to perform client side code on the click event:
     
    btnCancelNCODiv.Attributes.Add("onclick", "hideDIVNCO(); return false;") 
     
    when I try to do something similar on the Ajax uploader control, I notice that attributes is not a known property for the ajax uploader control?  Basically, I don't a post back to occur when the file finishes uploading.
     
    Any Thoughts or suggestions?
     
    Thank you. 
     
     
    Eric:
    Hi mchamo,
     
    Please refer to http://cutesoft.net/forums/thread/65579.aspx , the highlighted code set the destination folder.
     
     void Uploader_FileUploaded(object sender, UploaderEventArgs args)
    {
    //Copys the uploaded file to a new location.
    args.CopyTo("c:\\temp\\"+args.FileName);
    //You can also open the uploaded file's data stream.
    //System.IO.Stream data = args.OpenStream();
    }
    You can write customization code and change "c:\\temp\\"+args.FileName to the actual file name based on your requirement.
     
    Thanks for asking
  •  06-15-2011, 3:42 AM 67973 in reply to 67960

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi mchamo,
     
    First you need to know that, the uploader need to upload the file to the server, so the postback is necessary.
     
    If you need user finish some input or  similar situations and than postback to the server. Please try use manually upload. Below is the online demo.
     
    http://www.ajaxuploader.com/Demo/Start-uploading-manually.aspx
     
    Regards,
     
    ken
     
     
     
  •  06-15-2011, 10:12 AM 67979 in reply to 67973

    Re: Ajax Uploader - ManualStartUpload="true"

    thanks for your reply Ken.  I have reviewed this demo several times and I have looked at the source code but have not found a resolution to what I am trying to do.  Is there  a way to kick off some client side code on the FileUploaded event before heading back to the server event that handles the event?
     
     
     
     
     
    Kenneth:
    Hi mchamo,
     
    First you need to know that, the uploader need to upload the file to the server, so the postback is necessary.
     
    If you need user finish some input or  similar situations and than postback to the server. Please try use manually upload. Below is the online demo.
     
    http://www.ajaxuploader.com/Demo/Start-uploading-manually.aspx
     
    Regards,
     
    ken
     
     
     
  •  06-15-2011, 9:38 PM 67982 in reply to 67979

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi mchamo,
     
    Please try the example below. Function "CuteWebUI_AjaxUploader_OnSelect" will fire before the uploader control postback to the server. So you can execute your own script code in it before the "FileUploaded" event.
     
    <%@ Page Language="C#" %>

    <!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 id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <CuteWebUI:Uploader ID="Uploader1" runat="server">
            </CuteWebUI:Uploader>
        </form>
    </body>
    </html>
    <script>
    function CuteWebUI_AjaxUploader_OnSelect(files)

    {
        alert("before postback!");

    }
    </script>
     
    Regards,
     
    ken
  •  06-16-2011, 7:47 AM 67996 in reply to 67982

    Re: Ajax Uploader - ManualStartUpload="true"

    Ken, I tried your recommendation of using the 
    CuteWebUI_AjaxUploader_OnSelect javascript event.  The problem with this is that when using the manual start upload approach, the 
    CuteWebUI_AjaxUploader_OnSelect event kicks off as soon as you select a file for upload but not when you click your button to submit and actually begin the upload.  As a result, this event is too early.  I am looking for a JS event that  I can use which has 
    has access to the files selected for upload but that kicks off when uploadobj.startupload() is executed.
     
    For example, I think I might be able to achieve this using this event:
     

    function CuteWebUI_AjaxUploader_OnStart()

    {

    // Code goes here 
    } 
     
    But, I am not sure if I would be able to perform some code in the above mentioned event to perform the upload without going server side. Within the above JS event, I can access the AJAX uploader control with the key word this, can I use that to perform some JS code, for example, that would achieve the same thing as doinf this server side.
     
        Private Sub Uploader_FileUploaded(ByVal sender As Object, ByVal args As UploaderEventArgs)              
            args.CopyTo("C:\\" & Date.Now.ToShortDateString().Replace("/", "") + ".pdf")
        End Sub
     
    Any thoughts?  Thanks. 
     
     
    Kenneth:
    Hi mchamo,
     
    Please try the example below. Function "CuteWebUI_AjaxUploader_OnSelect" will fire before the uploader control postback to the server. So you can execute your own script code in it before the "FileUploaded" event.
     
    <%@ Page Language="C#" %>

    <!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 id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <CuteWebUI:Uploader ID="Uploader1" runat="server">
            </CuteWebUI:Uploader>
        </form>
    </body>
    </html>
    <script>
    function CuteWebUI_AjaxUploader_OnSelect(files)

    {
        alert("before postback!");

    }
    </script>
     
    Regards,
     
    ken
  •  06-17-2011, 12:59 AM 68009 in reply to 67996

    Re: Ajax Uploader - ManualStartUpload="true"

    Hi mchamo,
     
    Try API CuteWebUI_AjaxUploader_OnPostback
     
    Please refer to http://www.ajaxuploader.com/document/scr/JavaScript-API.htm
     
    EventsDescription
    CuteWebUI_AjaxUploader_OnInitializeFires when an Ajax Uploader is fully initialized.
    CuteWebUI_AjaxUploader_OnStartFires when an upload of a specific file has started.
    CuteWebUI_AjaxUploader_OnStopFires when upload is stopped and not do postback.
    CuteWebUI_AjaxUploader_OnPostbackFires before the page do PostBack to server side and fire the FileUploaded event.
    CuteWebUI_AjaxUploader_OnBrowseFires when the upload button is clicked.
    CuteWebUI_AjaxUploader_OnSelectFires when files are selected.
    CuteWebUI_AjaxUploader_OnProgressFires when new information about the upload progress for a specific file is available.
    CuteWebUI_AjaxUploader_OnQueueUIFires when the upload queue table is available.
     
     
    Regards,
     
    ken
View as RSS news feed in XML