SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't really got a problem just a question. After googling around I couldn't find any answer on what I'm looking for.

Is it possible to put a <asp:TreeView/> or multiple <asp:LinkButton/> so i can fastly navigate on my visual webpart?

Like this:

enter image description here

Hopefully i get some answers and tips here, I would appreciate it.

share|improve this question

Since the webpart will only have one "Page" I would use some javascript / jQuery for conditionally showing and hinding different elements on the page when the user clicks one of the links (could be normal <a>-tags with an onclick event).

So basically you render all of your controls at once from code behind, handles the updates from code-behind but uses javascript to show the correct information based on the users link choice.

share|improve this answer

yes you can and this person has done it, there is too much code to post:

obviously you would need to ammend the code! but its more to show you how he/she has done it and that it is possible! the tree view should already handle the min/max without the need of javascript / jquery

another example:

using (SPSite Site = new SPSite(SPContext.Current.Site.Url + "/UberWiki"))
    using (SPWeb currentWeb = Site.OpenWeb())
        // set the tree view properties
        SPList list = currentWeb.GetList(currentWeb.Url+"/Lists/Pages");

        SPFieldChoice field = (SPFieldChoice)list.Fields["Categories"];
        treeView = new System.Web.UI.WebControls.TreeView();

        // Add root nodes
        foreach (string str in field.Choices)
            rootNode = new System.Web.UI.WebControls.TreeNode(str);

        // Add child nodes
        foreach (SPListItem rows in list.Items)
            childNode = new System.Web.UI.WebControls.TreeNode(rows["Title"].ToString());

with those two examples you can easily make a treeview in a webpart that implements an ascx interface

You can also have the option of inserting the HTML direcly through code and using JS/JQ or within the button event handler that looks through the page to find the div control/ or whatever control to min/max or show/hide

share|improve this answer

Your Answer


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.