APNSoft Controls [4.5.2.20]
Menu > Templates


APNSoft Menu 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 MenuElement 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.MenuElement MenuElement = null;
                
    [VB.NET]
    Public MenuElement As APNSoft.WebControls.MenuElement = Nothing
                


Templates can include variables, instead of which data is inserted. Available variables:

Menu 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" />