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 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
add comment

2 Answers

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
add comment

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

http://dineshsharepoint.blogspot.co.uk/

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);
            treeView.Nodes.Add(rootNode);                        
        }

        // Add child nodes
        foreach (SPListItem rows in list.Items)
        {
            childNode = new System.Web.UI.WebControls.TreeNode(rows["Title"].ToString());
            treeView.FindNode(rows["Categories"].ToString()).ChildNodes.Add(childNode);
        }
    }
    this.Controls.Add(treeView);
    base.CreateChildControls();
}

http://stackoverflow.com/questions/11832212/programmatically-creating-a-treeview-in-sharepoint-based-on-a-column

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
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.