[CLOSED] Hyperlink AddClass - GetClass?

  1. #1

    [CLOSED] Hyperlink AddClass - GetClass?

    Hi,

    I can add a class to ext hyperlink using AddClass, but I cant get the class afterwards. Isnt there a GetClass?

    Thanks
    Last edited by Daniil; Sep 19, 2011 at 6:23 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The server side .AddClass() method just generates a respective JavaScript script to add a CSS class on client side.

    CSS class is not saved on server side and not automatically submitted from client side.

    You can send this info manually as an extra parameter.

    To get a CSS class:
    WidgetClientId.el.getAttribute("className")
    To checks if a specified CSS class exists:
    WidgetClientId.hasClass("someClass")
  3. #3
    Okay, so is there an option where I can change the css class of the hyperlink and also retrieve it?

    Thanks
  4. #4
    See the following sample
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <script runat="server">
        protected void SetClass(object sender, DirectEventArgs e)
        {
            HyperLink1.AddClass("my-class");
        }
    
    
        protected void GetClass(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Class", e.ExtraParams["class"]).Show();
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <style type="text/css">
            .my-class a{
                color:Red;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:HyperLink ID="HyperLink1" runat="server" Text="HyperLink" />
            
            <ext:Button runat="server" Text="Set class" OnDirectClick="SetClass" />
            <ext:Button runat="server" Text="Get class">
                <DirectEvents>
                    <Click OnEvent="GetClass">
                        <ExtraParams>
                            <ext:Parameter Name="class" Value="#{HyperLink1}.el.dom.className" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] hyperlink on GridPanel
    By cobiscorp in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 14, 2012, 11:22 AM
  2. [CLOSED] Xtemplate Hyperlink
    By RCM in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 16, 2012, 8:09 PM
  3. Replies: 2
    Last Post: Aug 15, 2011, 4:03 PM
  4. [CLOSED] Panel as hyperlink
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: May 25, 2011, 12:59 PM
  5. [CLOSED] Hyperlink Bug
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Feb 23, 2011, 8:28 AM

Posting Permissions