LoadXml custom attributes

2 posts, 0 answers
  1. Antony
    Antony avatar
    57 posts
    Member since:
    Oct 2008

    Posted 12 Jun 2009 Link to this post

    Hi Everyone,

    I am dynamically generating an XML string containing the structure of my RadPanelBar and then using LoadXML function.

    Is there any way to add additional attributes into the XML string and then access them from Server side/ Client side code?

    I have seen a few examples of using custom attributes when binding to an XML datasource but none of these appear to apply to using the LoadXML function.

    Any help appreciated.

  2. Paul
    Paul avatar
    4281 posts

    Posted 27 Aug 2009 Link to this post

    Hi Antony,

    Here's a sample code snippet that shows the needed approach.

    <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        <telerik:RadPanelBar ID="RadPanelbar1" runat="server" OnItemClick="RadPanelbar1_ItemClick" 
        <asp:Label ID="Label1" runat="server" Text="Label" Width="100%"></asp:Label> 

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.Web.UI; 
    public partial class _Default : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e) 
            if (!IsPostBack) 
        protected void RadPanelbar1_ItemClick(object sender, RadPanelBarEventArgs e) 
            Label1.Text = e.Item.Attributes["DocNamespace"]; 

    <?xml version="1.0" encoding="utf-8" ?> 
    <PanelBar xmlns=""
        <Item Text="2009 - 2010" Expanded="True"
            <Item Text="30/07/2009(M) 04" Value="4d03af79-e891-4e9b-ad70-2e8ae1b439db" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 
            <Item Text="30/06/2009(M) 03" Value="011904c7-01b3-41de-a4fa-e4371237ca01" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 
        <Item Text="2008 - 2009"
            <Item Text="31/03/2009(M) 12" Value="3185de0d-36c0-4f65-8cc3-9dc6755c8ee2" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 
            <Item Text="31/10/2008(M) 07" Value="d6d2e350-840d-49e0-a0c6-ccaf81b0dd91" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 
        <Item Text="2007 - 2008"
            <Item Text="30/11/2007(M) 08" Value="cf08d969-1846-4acd-ae9b-2a7ceb4e6a6c" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 
        <Item Text="2004 - 2005"
            <Item Text="31/03/2005(M) 12" Value="f5e11de7-bb90-4809-a5ba-4cae2717ef8d" DocNamespace="http://www.cintra.co.uk/EmployeeDocuments/Payslip/v1" /> 

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top