Change collapse image url in asp.net TreeView

TreeView collapse image url
TreeView CollapseImageUrl is the url to an image displayed for the collapsible node indicator. treeview collapse indicator image is usually a minus sign (-). if we want then we can change the default image of collapse indicator. treeview CollapseImageUrl property help us to change or set the collapse indicator image. we can set or change the treeviw collapse image url programatically at run time. the following c# examples source code demonstrate us the entire process.
TreeViewCollapseImageUrl.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        TreeView1.CollapseImageUrl = "~/Images/CollapseImage.gif";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        TreeView1.CollapseImageUrl = "~/Images/CollapseImage1.gif";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change collapse image url (CollapseImageUrl) in TreeView</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Green">TreeView Example: CollapseImageUrl</h2>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
        <asp:TreeView 
             ID="TreeView1"
             runat="server"
             DataSourceID="SiteMapDataSource1"
             Width="250"
             ForeColor="Crimson"
             Font-Bold="true"
             BorderColor="Crimson"
             BorderWidth="2"
             >
        </asp:TreeView>
        <br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SteelBlue"
             Text="Change Collapse Iamge Url"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SteelBlue"
             Text="Set Another Collapse Image"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
Web.sitemap
Web.sitemap source code here.

   


Related asp.net example