This is a migrated thread and some comments may be shown as answers.

RadTreeNode forecolor reverts back to default after postback

1 Answer 71 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Manas
Top achievements
Rank 1
Manas asked on 07 May 2012, 06:13 AM
Hi,

I have a radTreeView where I am adding nodes dynamically in form load event. I am assigning a forecolor to it.

RadTreeNode nodeLevel3 = new RadTreeNode(nodeNameL3, nodeIDL3);
nodeLevel3.Checkable = true;
nodeLevel3.ContextMenuID = "ctxMenuDisabled";
nodeLevel3.ForeColor = System.Drawing.Color.Blue;
parentNode.Nodes.Add(nodeLevel3);

The nodes show up blue perfectly. but the problem is after the initial page_load is complete, whenever I am deleting/editing or adding a node in the tree, a ajax postback takes place and the blue color disappears. it changes back to default black color.

How can I keep the custom colored nodes across postbacks?

1 Answer, 1 is accepted

Sort by
0
Manas
Top achievements
Rank 1
answered on 07 May 2012, 06:48 AM
Found the solution. Instead of assigning the color directly to the node, I used a css.

<style type="text/css">             
   .blueNode
   {
    color:blue;
   }            
</style>

then in my code behind, I am using this:

RadTreeNode nodeLevel3 = new RadTreeNode(nodeNameL3, nodeIDL3);
nodeLevel3.Checkable = true;
nodeLevel3.ContextMenuID = "ctxMenuDisabled";
nodeLevel3.CssClass = "blueNode";

It works like a charm!
Tags
TreeView
Asked by
Manas
Top achievements
Rank 1
Answers by
Manas
Top achievements
Rank 1
Share this question
or