RadTreeNode forecolor reverts back to default after postback

2 posts, 0 answers
  1. Manas
    Manas avatar
    5 posts
    Member since:
    Apr 2012

    Posted 07 May 2012 Link to this post

    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?
  2. Manas
    Manas avatar
    5 posts
    Member since:
    Apr 2012

    Posted 07 May 2012 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top