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

Represents a node in the RadSiteMap control.

The RadSiteMap control is made up of nodes. Nodes which are immediate children of the control are root nodes. Nodes which are children of other nodes are child nodes.

A node usually stores data in two properties, the Text property and the NavigateUrl property.

To create nodes, use one of the following methods:

  • Data bind the RadSiteMap control to a data source, for example SiteMapDataSource.
  • Use declarative syntax to define nodes inline in your page or user control.
  • Use one of the constructors to dynamically create new instances of the RadSiteMap class. These nodes can then be added to the Nodes collection of another node or site map.

When the user clicks a node, the RadSiteMap control navigates to the linked Web page. By default, a linked page is displayed in the same window or frame. To display the linked content in a different window or frame, use the Target property.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class RadSiteMapNode : NavigationItem, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IMarkableStateManager, IStateManager, INamingContainer, IXmlSerializable, IControlItemContainer, IRadSiteMapNodeContainer

Inheritance: objectControlWebControlControlItemNavigationItemRadSiteMapNode...

Implements: IAttributeAccessorIComponentIControlBuilderAccessorIControlDesignerAccessorIControlItemContainerIDataBindingsAccessorIDisposableIExpressionsAccessorIMarkableStateManagerINamingContainerIParserAccessorIRadSiteMapNodeContainerIStateManagerIUrlResolutionServiceIXmlSerializable...

Inherited Members NavigationItem.LoadFromDictionary(IDictionary<string, object>)NavigationItem.WriteXml(XmlWriter)NavigationItem.WriteXmlForChildren(XmlWriter)NavigationItem.ReadXml(XmlReader)NavigationItem.ReadXmlForChildren(XmlReader)NavigationItem.LoadChildViewState(object)NavigationItem.SaveChildViewState()NavigationItem.TrackChildViewState()NavigationItem.SetChildrenDirty()NavigationItem.AddedControl(Control, int)NavigationItem.ItemTextIsHTMLEncoded()ControlItem.GetHierarchicalIndex()ControlItem.GetAllChildren<TControlItem>()ControlItem.GetChildren<TControlItem>(Predicate<TControlItem>)ControlItem.FindChild<TControlItem>(Predicate<TControlItem>)ControlItem.IDControlItem.IndexControlItem.AccessKeyControlItem.TemplateControlItem.ContainerControlItem.RenderingCompatibilityControlItem.ChildrenWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.LoadViewState(object)WebControl.TrackViewState()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.SaveViewState()WebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.StyleWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.HeightWebControl.IsEnabledWebControl.SupportsDisabledAttributeWebControl.SkinIDWebControl.TabIndexWebControl.TagNameWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind()Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.OnInit(EventArgs)Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.Focus()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.OnLoad(EventArgs)Control.OnPreRender(EventArgs)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.CreateControlCollection()Control.CreateChildControls()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.UniqueIDControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initializes a new instance of the RadSiteMapNode class.

C#
public RadSiteMapNode()

Use this constructor to create and initialize a new instance of the RadSiteMapNode class using default values.

Example:
cs-api-definition
RadSiteMapNode node = new RadSiteMapNode();
node.Text = "News";
node.NavigateUrl = "~/News.aspx";

RadSiteMap1.Nodes.Add(node);

Initializes a new instance of the RadSiteMapNode class with the specified text, value and URL.

C#
public RadSiteMapNode(string text, string navigateUrl)
Parameters:textstring

The text of the node. The Text property is set to the value of this parameter.

navigateUrlstring

The url which the node will navigate to. The NavigateUrl property is set to the value of this parameter.

Use this constructor to create and initialize a new instance of the RadSiteMapNode class using the specified text, value and URL.

Example:
cs-api-definition
RadSiteMapNode node = new RadSiteMapNode("News", "~/News.aspx");

RadSiteMap1.Nodes.Add(node);

Properties

Gets or sets the Cascading Style Sheet (CSS) class applied by default to the node.

C#
[ClientPersistedProperty]
public override string CssClass { get; set; }

Overrides: WebControl.CssClass

By default the visual appearance of hovered nodes is defined in the skin CSS file. You can use the CssClass property to specify unique appearance for the node.

Gets the data item that is bound to the node

C#
[Browsable(false)]
public override object DataItem { get; set; }
Property Value:

An Object that represents the data item that is bound to the node. The default value is null (Nothing in Visual Basic), which indicates that the node is not bound to any data item. The return value will always be null unless accessed within a NodeDataBound event handler.

Overrides: ControlItem.DataItem

This property is applicable only during data binding. Use it along with the NodeDataBound event to perform additional mapping of fields from the data item to RadSiteMapNode properties.

Example:
cs-api-definition
private void RadSiteMap1_NodeDataBound(object sender, Telerik.Web.UI.RadSiteMapNodeEventArgs e)
{
e.Node.ImageUrl = "image" + (string)DataBinder.Eval(e.Node.DataItem, "ID") + ".gif";
e.Node.NavigateUrl = (string)DataBinder.Eval(e.Node.DataItem, "URL");
}

Gets or sets the Cascading Style Sheet (CSS) class applied to the node when it is disabled.

C#
[ClientPersistedProperty]
public string DisabledCssClass { get; set; }

By default the visual appearance of disabled nodes is defined in the skin CSS file. You can use the DisabledCssClass property to specify unique appearance for a node when it is disabled.

Gets or sets a value specifying the URL of the image rendered when the node is disabled.

C#
[ClientPersistedProperty]
public string DisabledImageUrl { get; set; }

If the DisabledImageUrl property is not set the ImageUrl property will be used when the node is disabled.

Gets or sets a value indicating whether the node is enabled.

C#
[ClientPersistedProperty]
public override bool Enabled { get; set; }
Property Value:

true if the node is enabled; otherwise false. The default value is true.

Overrides: ControlItem.Enabled

Disabled nodes cannot be clicked, or expanded.

Gets or sets the Cascading Style Sheet (CSS) class applied to the node when the mouse hovers it.

C#
[ClientPersistedProperty]
public string HoveredCssClass { get; set; }

By default the visual appearance of hovered nodes is defined in the skin CSS file. You can use the HoveredCssClass property to specify unique appearance for a node when it is hoevered.

Gets or sets a value specifying the URL of the image rendered when the node is hovered with the mouse.

C#
[ClientPersistedProperty]
public override string HoveredImageUrl { get; set; }

Overrides: NavigationItem.HoveredImageUrl

If the HoveredImageUrl property is not set the ImageUrl property will be used when the node is hovered.

Gets or sets the URL to an image which is displayed next to the text of a node.

C#
[ClientPersistedProperty]
public override string ImageUrl { get; set; }
Property Value:

The URL to the image to display for the node. The default value is empty string which means by default no image is displayed.

Overrides: NavigationItem.ImageUrl

Use the ImageUrl property to specify a custom image that will be displayed before the text of the current node.

Example:
C#
<p>
       The following example demonstrates how to specify the image to display for
       the node using the <b>ImageUrl</b> property.
   </p>
<p>
        &lt;telerik:RadSiteMap id="RadSiteMap1" runat="server"&gt;<br />
         &lt;Nodes&gt;<br />
         &lt;telerik:RadSiteMapNode<strong>ImageUrl="~/Img/inbox.gif"</strong>
        Text="Index"&gt;&lt;/telerik:RadSiteMapNode&gt;<br />
         &lt;telerik:RadSiteMapNode<strong>ImageUrl="~/Img/outbox.gif"</strong>
        Text="Outbox"&gt;&lt;/telerik:RadSiteMapNode&gt;<br />
         &lt;telerik:RadSiteMapNode<strong>ImageUrl="~/Img/trash.gif"</strong>
        Text="Trash"&gt;&lt;/telerik:RadSiteMapNode&gt;<br />
         &lt;telerik:RadSiteMapNode<strong>ImageUrl="~/Img/meetings.gif"</strong>
        Text="Meetings"&gt;&lt;/telerik:RadSiteMapNode&gt;<br />
         &lt;/Nodes&gt;<br />
        &lt;/telerik:RadSiteMap&gt;
</p>

Gets the level of the node.

C#
[Browsable(false)]
public int Level { get; }
Property Value:

An integer representing the level of the node. Root nodes are level 0 (zero).

Gets or sets the URL to navigate to when the current node is clicked.

C#
[ClientPersistedProperty]
public override string NavigateUrl { get; set; }
Property Value:

The URL to navigate to when the node is clicked. The default value is empty string which means that clicking the current node will not navigate.

Overrides: NavigationItem.NavigateUrl

Gets a RadSiteMapNodeCollection object that contains the child nodes of the current RadSiteMapNode.

C#
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadSiteMapNodeCollection Nodes { get; }
Property Value:

A RadSiteMapNodeCollection that contains the child nodes of the current RadSiteMapNode. By default the collection is empty (the node has no children).

Implements: IRadSiteMapNodeContainer.Nodes

Use the Nodes property to access the child nodes of the RadSiteMapNode. You can also use the Nodes property to manage the child nodes - you can add, remove or modify nodes.

Example:
cs-api-definition
RadSiteMapNode node = RadSiteMap1.FindNodeByText("Test");
node.Nodes[0].Text = "Example";
node.Nodes[0].NavigateUrl = "http://www.example.com";

Gets or sets the template for displaying the node.

C#
[TemplateContainer(typeof(RadSiteMapNode))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate NodeTemplate { get; set; }
Property Value:

An object implementing the ITemplate interface. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.

To specify common display for all nodes use the NodeTemplate property.

Example:
C#
<p>The following template demonstrates how to add an Image control in certain
     node.</p>
     <p>ASPX:</p>
        <p>
&lt;telerik: RadSiteMap runat="server" ID="RadSiteMap1"&gt;
    &lt;Nodes&gt;
        &lt;telerik:RadSiteMapNode Text="Root Node" &gt;
            &lt;Nodes&gt;
                &lt;telerik:RadSiteMapNode&gt;
                    &lt;NodeTemplate&gt;
                        &lt;asp:Image ID="Image1" runat="server" ImageUrl="MyImage.gif"&gt;&lt;/asp:Image&gt;
                    &lt;/NodeTemplate&gt;
                &lt;/telerik:RadSiteMapNode&gt;
            &lt;/Nodes&gt;
        &lt;/telerik:RadSiteMapNode&gt;
    &lt;/Nodes&gt;
&lt;/telerik:RadSiteMap&gt;
        </p>

Gets the parent IRadSiteMapNodeContainer.

C#
[Browsable(false)]
public IRadSiteMapNodeContainer Owner { get; }

Implements: IRadSiteMapNodeContainer.Owner

Gets the parent node of the current node.

C#
[Browsable(false)]
public RadSiteMapNode ParentNode { get; }
Property Value:

The parent node. If the the node is a root node null (Nothing) is returned.

C#
protected override IDictionary<string, string> PropertyMappings { get; }

Overrides: ControlItem.PropertyMappings

Gets or sets a value indicating whether the node is selected.

C#
public bool Selected { get; set; }
Property Value:

True if the node is selected; otherwise false. The default value is false.

Only one node can be selected.

Gets or sets the Cascading Style Sheet (CSS) class applied when node is selected.

C#
[ClientPersistedProperty]
public string SelectedCssClass { get; set; }

By default the visual appearance of selected nodes is defined in the skin CSS file. You can use the SelectedCssClass property to specify unique appearance for a node when it is selected.

Gets or sets a value specifying the URL of the image rendered when the node is selected.

C#
[ClientPersistedProperty]
public string SelectedImageUrl { get; set; }

If the SelectedImageUrl property is not set the ImageUrl property will be used when the node is selected.

Gets or sets the separator template for the node.

C#
[TemplateContainer(typeof(RadSiteMapNode))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate SeparatorTemplate { get; set; }
Property Value:

An object implementing the ITemplate interface. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.

To specify common display for all nodes use the SeparatorTemplate property.

The separator is rendered only in Flow mode.

Example:
C#
<p>The following template demonstrates how to add custom separator to a certain node.</p>
     <p>ASPX:</p>
        <p>
&lt;telerik: RadSiteMap runat="server" ID="RadSiteMap1"&gt;
    &lt;Nodes&gt;
        &lt;telerik:RadSiteMapNode Text="Root Node" &gt;
            &lt;Nodes&gt;
                &lt;telerik:RadSiteMapNode&gt;
                    &lt;SeparatorTemplate&gt;
                        &lt;asp:Image ID="Image1" runat="server" ImageUrl="MySeparator.gif"&gt;&lt;/asp:Image&gt;
                    &lt;/SeparatorTemplate&gt;
                &lt;/telerik:RadSiteMapNode&gt;
            &lt;/Nodes&gt;
        &lt;/telerik:RadSiteMapNode&gt;
    &lt;/Nodes&gt;
&lt;/telerik:RadSiteMap&gt;
        </p>

Gets the RadSiteMap which this node belongs to.

C#
[Browsable(false)]
public RadSiteMap SiteMap { get; }
Property Value:

The RadSiteMap which this node belongs to; null (Nothing) if the node is not added to any RadSiteMap control.

C#
protected override HtmlTextWriterTag TagKey { get; }

Overrides: WebControl.TagKey

Gets or sets the target window or frame in which to display the Web page content associated with the current node.

C#
[TypeConverter(typeof(TargetConverter))]
[ClientPersistedProperty]
public override string Target { get; set; }
Property Value:

The target window or frame to load the Web page linked to when the node is clicked. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:

_blankRenders the content in a new window without frames.
_parentRenders the content in the immediate frameset parent.
_selfRenders the content in the frame with focus.
_topRenders the content in the full window without frames.

The default value is empty string which means the linked resource will be loaded in the current window.

Overrides: NavigationItem.Target

Use the Target property to target window or frame in which to display the Web page content associated with the current node. The Web page is specified by the NavigateUrl property.

If this property is not set, the Web page specified by the NavigateUrl property is loaded in the current window.

The Target property is taken into consideration only when the NavigateUrl property is set.

Example:
C#
The following example demonstrates how to use the <b>Target</b> property

<p>
    <p>
       &lt;telerik:RadSiteMap id="RadSiteMap1" runat="server"&gt;<br />
    &lt;Nodes&gt;<br />
    &lt;telerik:RadSiteMapNode Text="News" NavigateUrl="~/News.aspx"
    <strong>Target="_self"</strong> /&gt;<br />
    &lt;telerik:RadSiteMapNode Text="External URL" NavigateUrl="http://www.example.com"
    <strong>Target="_blank"</strong> /&gt;<br />
    &lt;/Nodes&gt;<br />
    &lt;/telerik:RadSiteMap&gt;</p>
</p>

Gets or sets the text displayed for the current node.

C#
[ClientPersistedProperty]
public override string Text { get; set; }
Property Value:

The text displayed for the node in the RadSiteMap control. The default is empty string.

Overrides: ControlItem.Text

Use the Text property to specify or determine the text that is displayed for the node in the RadSiteMap control.

Gets or sets the tooltip shown for the node when the user hovers it with the mouse

C#
[ClientPersistedProperty]
public override string ToolTip { get; set; }
Property Value:

A string representing the tooltip. The default value is empty string.

Overrides: WebControl.ToolTip

The ToolTip property is also used as the alt attribute of the node image (in case ImageUrl is set)

Gets or sets custom (user-defined) data associated with the current node.

C#
[ClientPersistedProperty]
public override string Value { get; set; }
Property Value:

A string representing the user-defined data. The default value is emptry string.

Overrides: ControlItem.Value

Use the Value property to associate custom data with a RadSiteMap object.

Methods

C#
protected override void AddAttributesToRender(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: WebControl.AddAttributesToRender(HtmlTextWriter)

C#
protected override ControlItemCollection CreateChildItemCollection()
Returns:

ControlItemCollection

Overrides: ControlItem.CreateChildItemCollection()

Returns true if the control is rendered by the ControlItem itself; false if it was added by the user to the Controls collection.

C#
protected override bool IsChildControl(Control control)
Parameters:controlControlReturns:

bool

Overrides: ControlItem.IsChildControl(Control)

Removes the node from the Nodes collection of its parent

C#
public void Remove()
Example:
cs-api-definition
RadSiteMapNode node = RadSiteMap1.Nodes[0];
node.Remove();
C#
protected override void RenderContents(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: WebControl.RenderContents(HtmlTextWriter)

Renders the HTML closing tag of the control into the specified writer. This method is used primarily by control developers.

C#
public override void RenderEndTag(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

A HtmlTextWriter that represents the output stream to render HTML content on the client.

Overrides: WebControl.RenderEndTag(HtmlTextWriter)

C#
protected void RenderImage(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter
C#
protected override void SetItemContainer(ControlItemContainer itemContainer)
Parameters:itemContainerControlItemContainer

Overrides: NavigationItem.SetItemContainer(ControlItemContainer)