New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Server-side Events

RadSiteMap introduces two server-side events for working with nodes:

  • NodeCreated occurs when a new node is added to the control (at any level)
  • NodeDataBound occurs when a node is bound to a data source

This example shows how to use the NodeDataBound event to filter certain nodes. The nodes are then processed in the DataBound event and the total children count for each node is displayed.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="SiteMap.Examples.ServerEvents.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadSiteMapDataSource runat="server" ID="RadSiteMapDataSource1" ShowStartingNode="false"
        SiteMapFile="~/Examples.sitemap"></telerik:RadSiteMapDataSource>

    <div class="demo-container">
        <telerik:RadSiteMap runat="server" ID="SiteMap1" DataSourceID="RadSiteMapDataSource1"
            OnNodeDataBound="SiteMap1_NodeDataBound" OnDataBound="SiteMap1_DataBound">
            <LevelSettings>
                <telerik:SiteMapLevelSetting Level="0">
                    <ListLayout RepeatColumns="3" RepeatDirection="Horizontal" AlignRows="true"></ListLayout>
                </telerik:SiteMapLevelSetting>
            </LevelSettings>
            <DataBindings>
                <telerik:RadSiteMapNodeBinding NavigateUrl="#"></telerik:RadSiteMapNodeBinding>
            </DataBindings>
        </telerik:RadSiteMap>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance