Emad-ud-deen
Emad-ud-deen

Reputation: 4864

Setting the size of an image in an ASP.Net TreeView

How do you set the size of an image in an ASP.Net TreeView?

We tried to set the size like this but the images are showing in full size:

<asp:TreeView 
    runat="server"
    DataSourceID="KnowledgeAcademySiteMap">

    <RootNodeStyle ImageUrl="/Images/book.png" Height="32px" Width="32px" />
    <ParentNodeStyle ImageUrl="/Images/book.png" Height="32px" Width="32px" />
    <LeafNodeStyle ImageUrl="/Images/book.png" Height="32px" Width="32px" />
</asp:TreeView>

Upvotes: 4

Views: 6122

Answers (1)

Denys Wessels
Denys Wessels

Reputation: 17039

That height and width is applied to the tree view node, not to the image, that explains why the image size doesn't change.

You can either:

  1. Change the size of the image using photoshop, .NET Paint etc or
  2. Apply a CSS style rule to the images contained in the tree view, example:

CSS:

.treeView img { width:32px; height:32px; }

ASPX:

<asp:TreeView CssClass="treeView" ...

Upvotes: 7

Related Questions