Re: Pre-Upload Event

  •  07-07-2008, 1:54 AM

    Re: Pre-Upload Event

    Hi,
     
     
    We have made some research on your request.
     
    We recommand you implement your request by this way:
     
    Use custom UI button by setting the Uploader1.InsertButtonID="AnotherButton"
     
    then the uploader script would replace the AnotherButton.onclick=..
     
    You can replace it by this way :
     
     
     
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" Namespace="CuteWebUI" %>
    <!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>Yes..</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                Email :
                <asp:TextBox ID="TextBox1" runat="server" />
                <br />
                <asp:Button ID="Button1" runat="server" Text="Start Upload.." />
                <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertButtonID="Button1">
                </CuteWebUI:Uploader>
            </div>
        </form>
        <script>
       
        var inp1=document.getElementById('<%=TextBox1.ClientID %>');
        var btn1=document.getElementById('<%=Button1.ClientID %>');
        var int1;
        function MyClickHandler(event)
        {
            if(inp1.value.indexOf("@")==-1)
            {
                alert("Please input your email!");
                inp1.focus();
            }
            else
            {
                //Email OK! call the uploader script to browser the file and upload..
                btn1.uploaderclick();
            }
           
            //always cancel the onclick event, otherwise the form would do the postback!
            event=window.event||event;
            if(event.preventDefault)event.preventDefault();
            return event.returnValue=false;
        }
        function CheckUploaderScriptStatus()
        {
            //if the uploader script be loaded , the btn1.onclick would be setted
            //then you can replace it :
            if(btn1.onclick)
            {
                //stop the interval timer
                clearInterval(int1);
                //save the uploader handler
                btn1.uploaderclick=btn1.onclick;
                //use my own handler
                btn1.onclick=MyClickHandler;
            }
        }
        int1=setInterval(CheckUploaderScriptStatus,10);
       
        </script>
    </body>
    </html>
     
     
    Regards , Terry .
     
     
View Complete Thread