Uploader in dynamic UserControl

Last post 11-01-2012, 6:07 AM by benjib98. 1 replies.
Sort Posts: Previous Next
  •  10-31-2012, 2:28 PM 75123

    Uploader in dynamic UserControl

    Hi,
     
    I have issue with the Uploader in a dynamically loaded user control in an UpdatePanel. When the user control is loaded in an async postback everything loads fine until I try to submit the file selected for uploading. I am using a UploadAttachments for uploading a single file with ManualStartUpload="true". When the associated SubmitButton is clicked and the client submitbutton_click() is called I get an 
                "Object reference not set to an instance of an object."
    client error. Debugging the submitbutton_click() function it fails on the below line
                uploadobj.startupload();
    The client functions are stored in an external .js file which were copied from the sample pages from the CuteWebUI sample pages with minor changes for referencing the control IDs externally:

    var g_szSubmitButtonID ;

          function submitbutton_click(szSubmitButtonID, szUploaderID)
            {
                g_szSubmitButtonID = szSubmitButtonID;
                var submitbutton = document.getElementById(szSubmitButtonID);
                var uploadobj = document.getElementById(szUploaderID);
                if (!window.filesuploaded)
                {
                    if (uploadobj.getqueuecount() > 0)
                    {
                        uploadobj.startupload();
                    }
                    else
                    {
                        var uploadedcount = parseInt(submitbutton.getAttribute("itemcount")) || 0;
                        if (uploadedcount > 0)
                        {
                            return true;
                        }
                        alert("Please browse files for uploading");
                    }
                    return false;
                }
                window.filesuploaded = false;
                return true;
            }
            function CuteWebUI_AjaxUploader_OnPostback()
            {
                window.filesuploaded = true;
                var submitbutton = document.getElementById(g_szSubmitButtonID);
                submitbutton.click();
                return false;
            } 
    The generic message is no help at all, as I can't tell what is causing it. Anybody have an idea?
  •  11-01-2012, 6:07 AM 75127 in reply to 75123

    Re: Uploader in dynamic UserControl

    Just tested another control from the CuteWebUI library: Uploader from the "Simple Upload withProgress" sample to see how it will behave. On a simple ASPX page it works just fine but again when loaded asynchronuously using an ASCX user control the Uploader kicks out the same "Object reference not set to an instance of an object" error in a javascript popup. Actually if you just drop any uploader control on an ACX control which is async loaded, the Uploader button won't work unitl a "dummy" Uploader control is placed in the ASPX page with a style="display:none;". This is a usual workaround for all type of FileUploaders on the market incl. ASP.NET, 3rd party etc. This workaround makes the Uploader to start function as expcted, ie: the file browse window pops up but once again when a file is selected and the async uploading starts it ends up with the same error message like above. Could someone at CuteSoft have a look at this please? I'm not about to say how bad the library is, in fact looks great but it is a pain in the *** to debug something with this kind of generic error message. It would be more beneficial to rather throw an custom exception to aide with the debugging than just letting an unhandled exception being thrown.

     

    We would like to purchase license but until this test doesn't come back with a positive result it would be money thrown out the window as we load all our pages as ASCX user control in an async fashion.

     

    Many thanks,

    Ben

View as RSS news feed in XML