Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

PanelBar / Custom Attributes


  • Custom attributes are a convenient way to store custom data for panel items.

    There are three ways of defining custom attributes:

    • Define custom attributes inline (in the ASPX/ASCX file)
        <telerik:RadPanelItem Text="Inbox" runat="server" Messages="4" New="1" ... />  
      
    • Define custom attributes in the code-behind.

           [C#]
        RadPanelItem item = new RadPanelItem();
        item.Attributes["Messages"] = "4";					
        item.Attributes["New"] = "1";
      
           [VB]
        Dim item As RadPanelItem = New RadPanelItem()
        item.Attributes("Messages") = "4"
        item.Attributes("New") = "1"
    • Define custom attributes at the client-side:

       <script type="text/javascript">
         function setCustomAttributes ()
         {
       	var panelBar = $find("<%=RadPanelBar1.ClientID %>");
      
      var item1 = panelBar.get_items().getItem(0);
      //Pass the "AttributeName" and "AttributeValue" as parameters of the setAttribute method item1.get_attributes().setAttribute("Messages", "4");
      item1.get_attributes().setAttribute("New", "1");

      //You can obtain the value of a custom attribute like shown below
      //Pass the "AttributeName" as a parameter of the getAttribute method:

      var messagesCount = item1.get_attributes().getAttribute("Messages");
      } </script>

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>

    <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="true" Inherits="Telerik.Web.Examples.PanelBar.ApplicationScenarios.CustomAttributes.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server"></qsf:HeadTag>
        <link rel="stylesheet" href="styles.css" type="text/css" />
        <style type="text/css">
            
            dt, dl, dd
            {
                margin:0;
                padding:0;
            }
            dt
            {
                float:left;
                font-weight:bold;
                padding-right:10px;
                width:80px;
            }
            dl
            {
                width:90%;
                margin-left: 5px;
                float:left;
            }
            </style>
    </head>
    <body class="BODY">
        <form id="mainForm" method="post" runat="server">
            <telerik:RadScriptManager ID="ScriptManager" runat="server" />
            <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" ShowSkinChooser="false"></qsf:Header>
            <div id="qsfexWrapper">
                <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Width="200px" Skin="Outlook"
                    Height="370px" ExpandMode="FullExpandedItem">
                    <ItemTemplate>
                        <telerik:RadToolTip runat="server" ID="ToolTip1" Width="220px" Height="60px" RelativeTo="Element"
                            OffsetX="230" OffsetY="-30" ShowCallout="false">
                            <dl>
                                <dt>From: </dt>
                                <dd>
                                    <%#Container.Attributes("SenderName")%>
                                </dd>
                                <dt>Subject: </dt>
                                <dd>
                                    <%#Container.Attributes("Subject")%>
                                </dd>
                            </dl>
                        </telerik:RadToolTip>
                    </ItemTemplate>
                    <Items>
                        <telerik:RadPanelItem Expanded="True" Text="Inbox" runat="server" Messages="8" New="3"
                            Size="114,30KB" LastDate="24/12/2007" ImageUrl="Img/inbox.gif">
                            <ItemTemplate>
                                <telerik:RadToolTip runat="server" ID="ToolTip1" Width="200px" Height="60px" RelativeTo="Element"
                                    OffsetX="220" OffsetY="-30" ShowCallout="false">
                                    <dl>
                                        <dd>
                                            <strong>
                                                <%#Container.Attributes("Messages")%>
                                                Messages</strong><span style="color: Red"> (<%#Container.Attributes("New")%>
                                                    New)</span>
                                        </dd>
                                        <dd>
                                            <%#Container.Attributes("Size")%>
                                            on disk
                                        </dd>
                                        <dd>
                                            <i>Last archived:
                                                <%#Container.Attributes("LastDate")%>
                                            </i>
                                        </dd>
                                    </dl>
                                </telerik:RadToolTip>
                            </ItemTemplate>
                            <Items>
                                <telerik:RadPanelItem SenderName="John Sith" Subject="Weekly Report" Text="Weekly Report"
                                    runat="server" ImageUrl="Img/5.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Peter Howlett" Subject="Product Delivery" Text="Product Delivery"
                                    ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Marry Johnes" Subject="Product Newsletter" Text="Product Newsletter"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Sarah Smith" Subject="Product Feedback" Text="Product Feedback"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Benita Pyle" Subject="Feature_Request - RadControls"
                                    Text="Product feature request" runat="server" ImageUrl="Img/5.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Carina Cox" Subject="Forum - RadControls Sharepoint"
                                    Text="Forum - RadControls Sharepoint" runat="server" ImageUrl="Img/5.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Olive Pratt" Subject="Support - RadControls" Text="Support - RadControls"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Irving Saline" Subject="RadControls DNN" Text="RadControls DNN"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="Outbox" runat="server" Messages="4" Size="87,50 KB" LastDate="08/02/2008"
                            ImageUrl="Img/outbox.gif">
                            <ItemTemplate>
                                <telerik:RadToolTip runat="server" ID="ToolTip1" Width="200px" Height="60px" RelativeTo="Element"
                                    OffsetX="220" OffsetY="-30" ShowCallout="false">
                                    <dl>
                                        <dd>
                                            <strong>
                                                <%#Container.Attributes("Messages")%>
                                                Messages</strong>
                                        </dd>
                                        <dd>
                                            <%#Container.Attributes("Size")%>
                                            on disk
                                        </dd>
                                        <dd>
                                            <i>Last archived:
                                                <%#Container.Attributes("LastDate")%>
                                            </i>
                                        </dd>
                                    </dl>
                                </telerik:RadToolTip>
                            </ItemTemplate>
                            <Items>
                                <telerik:RadPanelItem SenderName="Joe Schmoe" Subject="Meeting!" Text="Meeting!"
                                    runat="server" ImageUrl="Img/3.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Ami Davolio" Subject="Schedule" Text="Schedule"
                                    runat="server" ImageUrl="Img/3.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Olive Pratt" Subject="RE: Support - RadControls"
                                    Text="RE: Support - RadControls" runat="server" ImageUrl="Img/3.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Irving Saline" Subject="RE: RadControls DNN" Text="RE: RadControls DNN"
                                    runat="server" ImageUrl="Img/3.gif" />
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="Drafts" runat="server" Messages="2" Size="100,0 KB" LastDate="24/12/2007">
                            <ItemTemplate>
                                <telerik:RadToolTip runat="server" ID="ToolTip1" Width="200px" Height="60px" RelativeTo="Element"
                                    OffsetX="220" OffsetY="-30" ShowCallout="false">
                                    <dl>
                                        <dd>
                                            <strong>
                                                <%#Container.Attributes("Messages")%>
                                                Messages</strong>
                                        </dd>
                                        <dd>
                                            <%#Container.Attributes("Size")%>
                                            on disk
                                        </dd>
                                        <dd>
                                            <i>Last archived:
                                                <%#Container.Attributes("LastDate")%>
                                            </i>
                                        </dd>
                                    </dl>
                                </telerik:RadToolTip>
                            </ItemTemplate>
                            <Items>
                                <telerik:RadPanelItem SenderName="Joe Schmoe" Subject="Meeting!" Text="Meeting!"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Ami Davolio" Subject="Schedule draft" Text="Schedule draft!"
                                    runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Olive Pratt" Subject="RE: Support - RadControls"
                                    Text="RE: Support - RadControls" runat="server" ImageUrl="Img/4.gif">
                                </telerik:RadPanelItem>
                                <telerik:RadPanelItem SenderName="Irving Saline" Subject="RE: RadControls DNN" Text="RE: RadControls DNN"
                                    runat="server" ImageUrl="Img/4.gif" />
                            </Items>
                        </telerik:RadPanelItem>
                    </Items>
                    <CollapseAnimation Duration="100" Type="None" />
                    <ExpandAnimation Duration="100" Type="None" />
                </telerik:RadPanelBar>
            </div>
            <qsf:Footer ID="Footer1" runat="server"></qsf:Footer>
            <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server">
            </telerik:RadToolTipManager>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451