Uploader in dynamic UserControl

  •  10-31-2012, 2:28 PM

    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?
View Complete Thread