global functions not firing

Last post 10-21-2010, 8:36 PM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  10-21-2010, 9:15 AM 64557

    global functions not firing

    Hi!
    for me following functions are not firing up
     
     
    function CuteWebUI_AjaxUploader_OnInitialize(e) { }
    function CuteWebUI_AjaxUploader_OnStart(e) {  }
    function CuteWebUI_AjaxUploader_OnStop(e) {}
    function CuteWebUI_AjaxUploader_OnPostback(e) { }
    function CuteWebUI_AjaxUploader_OnBrowse(e) { }
    function CuteWebUI_AjaxUploader_OnSelect(e) { }
    function CuteWebUI_AjaxUploader_OnProgress(e) { }
    function CuteWebUI_AjaxUploader_OnQueueUI(e) {} 
     
     
     
    only function CuteWebUI_AjaxUploader_OnInitialize(e) { }  is firing up
     
    please! tell me the way to make them work. 
     
    thanks! 
     
     
     
     
  •  10-21-2010, 9:42 AM 64558 in reply to 64557

    Re: global functions not firing

    Dear deepakkumarjoshi,
     
    Please save the following snippet to "test.aspx", and then run it, it works fine.

    <%@ Page Language="C#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }
        void Attachments1_AttachmentAdded(object sender, AttachmentItemEventArgs args)
        {
            InsertMsg(args.Item.FileName + " has been uploaded.");
        }
        void ButtonDeleteAll_Click(object sender, EventArgs e)
        {
            InsertMsg("Attachments1.DeleteAllAttachments();");
            Attachments1.DeleteAllAttachments();
        }
        void ButtonTellme_Click(object sender, EventArgs e)
        {
            ListBoxEvents.Items.Clear();
            foreach (AttachmentItem item in Attachments1.Items)
            {
                InsertMsg(item.FileName + ", " + item.FileSize + " bytes.");
                //Copies the uploaded file to a new location.
                //item.CopyTo("c:\\temp\\"+item.FileName);
                //You can also open the uploaded file's data stream.
                //System.IO.Stream data = item.OpenStream();
            }
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Uploading multiple files like GMail</title>
        <link rel="stylesheet" href="demo.css" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <div class="content">
                <h2>
                    Uploading multiple files like GMail</h2>
                <p>
                    Google's GMail has a nice way of allowing you to upload multiple files. Rather than
                    showing you 10 file upload boxes at once, the user attaches a file, you can click
                    a button to add another attachment.
                </p>
                <br />
                <CuteWebUI:UploadAttachments InsertText="Upload Multiple files Now" runat="server"
                    ID="Attachments1" MultipleFilesUpload="true" OnAttachmentAdded="Attachments1_AttachmentAdded">
                    <InsertButtonStyle />
                </CuteWebUI:UploadAttachments>
                <br />
                <br />
                <asp:Button ID="ButtonDeleteAll" runat="server" Text="Delete All" OnClick="ButtonDeleteAll_Click" />&nbsp;&nbsp;
                <asp:Button ID="ButtonTellme" runat="server" Text="Show Uploaded File Information"
                    OnClick="ButtonTellme_Click" />
                <br />
                <br />
                <div>
                    Server Trace:
                    <br />
                    <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
                </div>
            </div>
    <script type="text/javascript">
        //Fires when an Ajax Uploader is fully initialized
    function CuteWebUI_AjaxUploader_OnInitialize()
    {
        alert("CuteWebUI_AjaxUploader_OnInitialize is called");
        var hidden=this;
        //warning , using the internalobject is not recommend .
        //if you use it, you need test the uploader again for each new version.
        var arr=[];
        for(var p in hidden.internalobject)
        {
           arr.push(p);
        }
        alert("internal object member list : "+arr);
    }
    //Fires when an upload of a specific file has started
    function CuteWebUI_AjaxUploader_OnStart()
    {
      alert("CuteWebUI_AjaxUploader_OnStart is called");  
    }
    //Fires when upload is stopped and not do postback
    function CuteWebUI_AjaxUploader_OnStop()
    {
      alert("CuteWebUI_AjaxUploader_OnStop is called"); 
    }
    //Fires before the page do PostBack to server side and fire the FileUploaded event.
    function CuteWebUI_AjaxUploader_OnPostback()
    {
      alert("CuteWebUI_AjaxUploader_OnPostback is called");  
    }
    //Fires when the upload button is clicked.
    function CuteWebUI_AjaxUploader_OnBrowse()
    {
      alert("CuteWebUI_AjaxUploader_OnBrowse is called");
        //return false to cancel it..
    }
    //Fires when files are selected.
    function CuteWebUI_AjaxUploader_OnSelect(files)
    {
      alert("CuteWebUI_AjaxUploader_OnSelect is called");
        //change the files array would take no effect.
        var name=files[0].FileName;
        var size=files[0].FileSize // (or -1)
        //return false to cancel it..
    }
    //Fires when new information about the upload progress for a specific file is available.
    function CuteWebUI_AjaxUploader_OnProgress(enable,filename,begintime,uploadedsize,totalsize)
    {
      alert("CuteWebUI_AjaxUploader_OnProgress is called");  
    }
    //Fires when the upload queue table is available.

    function CuteWebUI_AjaxUploader_OnQueueUI(list)
    {
      alert("CuteWebUI_AjaxUploader_OnQueueUI is called");
        var name=list[0].FileName
        var size=list[0].FileSize // (or -1)
        var stat=list[0].Status // Finish|Error|Upload|Queue
        var func=list[0].Cancel;
    }   
        </script>
      </form>
    </body>
    </html>

    Thank you for asking
    [email protected]
  •  10-21-2010, 12:45 PM 64561 in reply to 64558

    Re: global functions not firing

    Hi!  thanks! for the reply, ur code worked fine, but in my case im using the global functions as well as the instance handlers , instance handlers are firing up but not the global, whats the difference between thses two??
    and both can be used together, if ues then how?
     
    my main requirement is to prevent the building of  queue table  and the file uploaded list table after the upload done, plz help me
     
    thanks! 
  •  10-21-2010, 8:36 PM 64575 in reply to 64561

    Re: global functions not firing

    Hi,
     
    The global handler is called by the default instance handler.
     
    If you replace the default instance handler, the global handler will not be called.
     
    So you need do that in the instance handler :
     
    uploader.handlepostback=function()
    {
       var res;
        if(window.CuteWebUI_AjaxUploader_OnPostback)
             res=window.CuteWebUI_AjaxUploader_OnPostback();
        if(res===false)
        {
            ///
        }
        ///
    }
     
    or this style :
     
    var oldhandler=uploader.handlepostback;
    uploader.handlepostback=function()
    {
       var res=oldhandler();
        if(res===false)
        {
            ///
        }
        ///
    }
     
    Regards,
    Terry
     
View as RSS news feed in XML