APNSoft.com - Web Controls, components for ASP.NET
 About Us 
 Articles 
 Products
 Downloads 
 Purchase
 Support

TreeView
Controls Suite 4.5


Overview
Features
Reference Book
Component Parts
Deployment
Defining the Structure
Appearance Customization
Templates
Server-side API
Live Demos




APNSoft TreeView supports three types of user-defined templates for additional item customization. Templates are easy to use powerful tools, which allow changing item's appearance flexibly on developer's demand.

  1. HTML template
    HTML Template is a regular text file with HTML elements: tables, images, controls, etc.


  2. XSL template
    XSL Template is more flexible than HTML template, because it includes XSL elements. XSL Template allows comparing/modifying data without a loss in performance. For example, under conditional formatting you must first analyze item's data and then apply the formatting.

    XSL Template must include two key elements: the <xsl:call-template name="Main" /> and the <xsl:template name="Main">. Sample code of XSL Template:

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" version="1.0" indent="no" omit-xml-declaration="yes" />
    
        <xsl:template match="/">
            <xsl:call-template name="Main" />
        </xsl:template>
    
        <xsl:template name="Main">
            ...
        </xsl:template>
    
    </xsl:stylesheet>
    


  3. ASCX template (User Control)
    ASCX Template is most flexible because it allows developer to format an item by using the preferred programming language (C# or VB.NET). ASCX Template can include the field TreeViewElement which must be declared as public. You can use this field to have access to the item in Template's code.


    [C#]
    public APNSoft.WebControls.TreeViewElement TreeViewElement = null;
                
    [VB.NET]
    Public TreeViewElement As APNSoft.WebControls.TreeViewElement = Nothing
                


Templates can include variables, instead of which data is inserted. Available variables:
  • $ComponentID$ - displays the unique identifier of the component.
  • $ItemID$ - displays the unique identifier of the item.
  • $Title$ - displays the text (caption) of the item.


TreeView automatically identifies the type of applicable template. To apply template to the item, use the Template attribute:

<item title="HTML" Template="~/Templates/Template.html" />
<item title="XSL" Template="~/Templates/Template.xsl" />
<item title="ASCX" Template="~/Templates/Template.ascx" />





© 2003-2024 APNSoft. All rights reserved.    Terms of use.