Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using an customized SPTreeView (UserControl) embed on the masterpage, any ideas how to set the selectedNode that correspond to the contextWeb or using another approach?

spregards

share|improve this question
add comment

2 Answers

That's little tricky.. Let's assume you have following binding for your SPTreeview

<DataBindings>
                <asp:TreeNodeBinding SelectAction="Select" NavigateUrlField="" TextField="EncodedName"
                    Target="_blank" ValueField="Name" />
            </DataBindings>

Then, in PreRender, you need to set the SelectedNodePath as shown below

 protected override void OnPreRender(EventArgs e)
        {

                WebTreeView.SelectedNodePath = "value that corresponds to current web";

        }
share|improve this answer
    
thanks for the reply @ashish-patel, but still not working. protected override void OnPreRender(EventArgs e) { var web = SPControl.GetContextWeb(Context); WebTreeView.SelectedNodePath = web.Url; WebTreeView.AutoExpandSelectedNode = true; } –  fallout Feb 14 '12 at 9:20
add comment
up vote 0 down vote accepted

using TreeView instead of SPTreeView:

protected void LeftNavTreeView_OnPreRender(object sender, EventArgs e)
                {
                        LeftNavTreeView.CollapseAll();

                        var treeNodeToExpand = LeftNavTreeView.SelectedNode;

                        while (treeNodeToExpand != null)
                        {
                                treeNodeToExpand.Expand();
                                treeNodeToExpand = treeNodeToExpand.Parent;
                        }
                }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.