Click Listeners for HyperLink, ext.net ?

  1. #1

    Click Listeners for HyperLink, ext.net ?

    Hello friends ,
    I wanna add a Click Handler to an ext.net's HyperLink :
    The following code returns a compile error :

     FileHyperLink.Listeners.Click.Handler = "return false;";
    How can I do it ?

    P.S:
    I've used LinkButton, but when I change its NavigateUrl in code behind , it doesn't apply to Linkbutton ?!!!
  2. #2
    Hi,


    Quote Originally Posted by Mohammad View Post
    I wanna add a Click Handler to an ext.net's HyperLink :
    The following code returns a compile error :

     FileHyperLink.Listeners.Click.Handler = "return false;";
    How can I do it ?
    Well, there is no Click listener.

    You can add Click listener for its Element.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void DisableLink(object sender, DirectEventArgs e)
        {
            HyperLink1.Element.AddListener("click", new JFunction() { Fn = "disable" });
        }
    </script>
    
    <!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>Ext.Net Example</title>
    
        <script type="text/javascript">
            var disable = function (e) {
                e.stopEvent();
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:HyperLink 
                ID="HyperLink1" 
                runat="server" 
                Text="Ext.Net"
                NavigateUrl="http://ext.net"
                Target="_blank" />
            <ext:Button runat="server" Text="DisableLink" OnDirectClick="DisableLink" />
        </form>
    </body>
    </html>
    Quote Originally Posted by Mohammad View Post
    I've used LinkButton, but when I change its NavigateUrl in code behind , it doesn't apply to Linkbutton ?!!!
    It works for me. What Ext.Net version do you use? If lower than 1.2, then I'd recommend to update.

    Example

           
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void ChangeUrl(object sender, DirectEventArgs e)
        {
            this.LinkButton1.Text = "Google";
            this.LinkButton1.NavigateUrl = "http://google.com";
        }
    </script>
    
    <!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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:LinkButton 
                ID="LinkButton1" 
                runat="server" 
                Text="Ext.Net"
                NavigateUrl="http://ext.net"
                Target="_blank" />
            <ext:Button runat="server" Text="Change an url" OnDirectClick="ChangeUrl" />
        </form>
    </body>
    </html>
  3. #3

    I updated , but it doesn't work yet ?

    I wanna to change LinkButton's Navigation Url in the ajax request ?

    protected void ButtonEdit_Click(object sender, DirectEventArgs e)
    {
        //....
        if (selectedNews.FilePath == null)
        {
            FileLinkButton.Text = "No File Attached";
            FileLinkButton.NavigateUrl = "#";
            FileLinkButton.Icon = Icon.Decline;
            FileLinkButton.Listeners.Click.Clear(); 
            FileLinkButton.Listeners.Click.Handler = "return false;";
        }
        else
        {
            FileLinkButton.NavigateUrl = ".." + selectedNews.FilePath;//It doesn't apply
            FileLinkButton.Text = "Download The File";
            FileLinkButton.Icon = Icon.Accept;
            FileLinkButton.Listeners.Click.Clear();
        }
        HiddenFiledID.Text = id.ToString();
    }
  4. #4
    I've just tried my example with the assemblies I downloaded from the official link:
    http://www.ext.net/archives/1-2-0/ex...munity.1.2.zip
    and it works fine.

    Please provide your full test case to check.
  5. #5

    Solved

    Quote Originally Posted by Daniil View Post
    I've just tried my example with the assemblies I downloaded from the official link:
    http://www.ext.net/archives/1-2-0/ex...munity.1.2.zip
    and it works fine.

    Please provide your full test case to check.
    With Your Assemblies my problem has solved. Thanks

Similar Threads

  1. Replies: 6
    Last Post: Jul 24, 2012, 7:23 PM
  2. Replies: 4
    Last Post: Aug 23, 2011, 3:03 PM
  3. [CLOSED] TreePanel + Listeners + Click/BeforeClick
    By state in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 24, 2009, 7:21 PM
  4. Q: Button Listeners.Click Question
    By bruce in forum 1.x Help
    Replies: 1
    Last Post: Mar 17, 2009, 2:31 AM
  5. Listener - force hyperlink.click() not working
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Feb 27, 2009, 5:47 AM

Tags for this Thread

Posting Permissions