Bolding TreeNode Text in Web Control
I have a web application with a TreeView/TreeNode I want it so when I select a topic it bolds the text. I can set up an OnSelectedNodeChanged event in the ASPX page and change the text to bold there.
But I need to be able to do it from Javascript with the node set to Navigate mode rather than Select mode. I'm trying to do it through callbacks. The javascript sends a callback to the server with the ValuePath of the tree node. I then try and do this:
TreeView treeView = GetCurrentTreeView(); // Gets the current displayed tree view
TreeNode node = treeView.FindNode(argument); // This returns the correct node
node.Text = "<b>" + node.Text + "</b>"; // This shows up as changing in the debugger
// It does not stay changed
But bolding the text seems to just be ignored. It doesn't show up on the page, and if I click again the bolding is gone in the debugger.
I k开发者_Go百科now adding bold tags works when I do this inside the OnSelectedNodeChanged event handler.
What's going on? Is there anyway to do this?
There's no option to change the TreeNode to use Select mode. I need to have C# server side code be able to change the text to bold too (aka I need to change it at times when a user clicks on a completely unrelated portion of the site).
I ended up putting it inside an update panel and changing the TreeView to use Select mode (so the postback happened).
There didn't seem to be any way to get the desired effect using Navigate and Javascript only.
精彩评论