Skip to main content
A newer version of this page is available. .

ASPxClientTreeViewNode.SetImageUrl(value) Method

Sets the URL which points to the image displayed within the node.

Declaration

SetImageUrl(
    value: string
): void

Parameters

Name Type Description
value string

A string value specifying the URL to the image displayed within the node.

Remarks

Use the SetImageUrl method to specify the URL to the image displayed within the ASPxClientTreeViewNode. In order to determine the node image’s URL, use the ASPxClientTreeViewNode.GetImageUrl method on the client side.

All graphic file formats which can be interpreted by internet browsers are supported. The image’s URL can specify either an absolute or relative path.

Note

If a node image is not initialized on the server side (the node’s TreeViewNode.Image.Url and control’s TreeViewImages.NodeImage.Url properties are not specified), the corresponding DOM element is not created. In this case, the SetImageUrl property is not in effect.

Example

The code below demonstrates how you can define node images and change them, when expanding and collapsing nodes on the client side.

using DevExpress.Web.ASPxTreeView;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
       DataBind();
       DefineImages(ASPxTreeView1.Nodes);
    }
    protected void DefineImages(TreeViewNodeCollection nodes) {
        foreach (TreeViewNode node in nodes) {
            if (node.Nodes.Count > 0) {
                node.Image.Url = "~/Images/closed_folder.png";
                DefineImages(node.Nodes);
            }
            else {
                node.Image.Url = "~/Images/file.png";
            }
        }
    }
}
See Also