Client Side Events

Last post 08-28-2008, 12:08 PM by ryanstinson. 3 replies.
Sort Posts: Previous Next
  •  08-21-2008, 5:05 PM 43150

    Client Side Events

    When I use a custom button the AjaxUploader seems to keep my client side click event from firing before opening the browser window. Is there any client side events on the AjaxUploader? or can I still have my button fire its click event before the browser opens?
  •  08-22-2008, 1:41 PM 43194 in reply to 43150

    Re: Client Side Events

    ryanstinson,
     
    Do you mean you use a custom button for upload and attache your own javascript event to this same button?
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-23-2008, 1:18 AM 43209 in reply to 43150

    Re: Client Side Events

    Hi ryanstinson,
     
     
     
    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 , Ken .
  •  08-28-2008, 12:08 PM 43346 in reply to 43209

    Re: Client Side Events

    Thanks Ken! That's what I needed.
View as RSS news feed in XML