- How to use custom image in a TreeView

Custom images in a TreeView
The TreeView is an web server control. The TreeView is located under System.Web.UI.WebControls namespace. TreeView web server control displays hierarchical data. Such as a table of contents in a tree structure.

The following c# tutorial code demonstrates how we can use custom images in a TreeView web server control. The c# developers can alter the appearance of the control is to customize the images that are displayed in the TreeView control.

The c# developers can specify their own custom set of images for the different parts of the TreeView control by setting the CollapseImageUrl, ExpandImageUrl, LineImagesFolder and NoExpandImageUrl property.

The TreeView CollapseImageUrl property is the URL to an image displayed for the collapsible node indicator. This image is usually a minus sign (-). The ExpandImageUrl is the URL to an image displayed for the expandable node indicator. This image is usually a plus sign (+).

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">


<html xmlns="">
<head runat="server">
    <title>How to use custom image in TreeView Control</title>
    <form id="form1" runat="server">
        <h2 style="color:Red">TreeView Example: Using Custom Image</h2>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="" >
  <siteMapNode url="~/Default.aspx" title="Home" description="Home Page">
    <siteMapNode url="~/Design.aspx" title="Design"  description="Design Tools">
      <siteMapNode url="~/Photoshop.aspx" title="Photoshop"  description="Adobe Photoshop" />
      <siteMapNode url="~/Firaworks.aspx" title="Firaworks"  description="Adobe Firaworks" />
    <siteMapNode url="~/Development.aspx" title="Development"  description="Development Tools">
      <siteMapNode url="~/ColdFusion.aspx" title="ColdFusion"  description="Adobe ColdFusion" />
      <siteMapNode url="~/aspnet.aspx" title=""  description="Microsoft" />
More examples