Solved

Expandable list of URLs

Posted on 2013-01-11
7
486 Views
Last Modified: 2013-01-15
I'm trying to build a heirarchical list of web sites in our environment.  We have about 1500 sites and I am able to traverse the tree and list the sites, but because of the amount, the page takes 12+ seconds to load.

I would like to rebuild this to only bring back one level at a time.  Each time I click the [+] sign I'd like to generate a tree branch 1 level deep just for that URL.

Example:

[+] Site 1
[+] Site 2
[-] Site 3
   [+] Sub site 1
   [-] Sub site 2
      [+] Sub Sub site 1
[+] Site N
etc...

I have all the code I need to generate each piece.  I can get a single level list of sites based on a URL.

My problem is displaying this and getting to to work right.  When the [+] is clicked the GetSubsites(URL) will fire.  But if "Site 1" is clicked, I want the user to be sent to Site 1.
I need help on the [+] generation/clicking and the displaying of the list as a sub list of the one I clicked.

Thanks
Ron
0
Comment
Question by:Capt_Ron
  • 4
  • 2
7 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 38768648
You can use asp.net treeview, check:

http://msdn.microsoft.com/en-us/library/7a9swst5.aspx

You need to:
- Add your treenodes in code and specify NavigateUrl property.
- Add nodes dynamically using the TreeNodePopulate
 event handler
- the example is using a datasource but you can adapt it to your needs.
0
 
LVL 1

Author Comment

by:Capt_Ron
ID: 38770258
I've looked at the example and I'm still confused on one part.
I can load the root level fine.  But how do I show the [+] sign if there are no nodes yet?  I can click the Root node and go to the URL, but I have no way of expanding it because the sub nodes aren't there yet.

I must be missing something.
Thanks
Ron
0
 
LVL 14

Expert Comment

by:KoenVosters
ID: 38773572
With these kind of things you have to take into account that you are opening the spsite and spweb objects to get all the information.

What I would suggest is that you have a daily timer job running (or hourly) that creates the hierarchy in XML and go from there.

You can use the following to get the subinformation of your sites:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://localhost"))
            {
                using (SPWeb web = site.OpenWeb("test"))
                {
                    string format = "{0, -30} {1, -5} {2}";
                    Console.WriteLine(format, "Title", "Id", "Url");

                    foreach (SPNavigationNode node in web.Navigation.GlobalNodes)
                    {
                        Console.WriteLine(format, node.Title, node.Id, node.Url);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.ReadLine();
        }
    }
}
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:Capt_Ron
ID: 38774154
Thank you.
We thought of that but we need the list to be security trimmed.
SharePoint 2010 removed the My Links list and we are trying to replace it. (Without it's limitations)

Our Thought process is:
Get a list of all site collections and check the logged in user's security.
When the [+] is clicked next to a site collection, go get the next level (check security)
Repeat for every level of sub sites

This way we are only getting one level at a time.

We've successfully done this for all sites at all levels, but the load time is 12+seconds and is unacceptable.

We're trying to reduce the load time by only getting one level at a time.

Thanks
Ron

PS: Once we figure this out, I'll post the code to whomever would like it. :-)
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 38776849
You can do that by populate the nodes in the TreeView dynamically.
Can you post your code/markup? It seems that Populates nodes may not be setup correctly.

Thanks,
Note: Another alternative that I used before if the treeview gets very slow because of the number of nodes, it is third party vendor called obout tree.
0
 
LVL 1

Author Closing Comment

by:Capt_Ron
ID: 38779926
Had to implement the TreeNodePopulate event handler properly.
0
 
LVL 1

Author Comment

by:Capt_Ron
ID: 38779952
Thank you so much.  My developer was able to implement the TreeNodePopulate event handler properly and the dynamic population started working the way I expected it to.  We are now loading over 1000 SharePoint sites into the list in about 1.5 to 2 seconds.  Much better than the 12 seconds before.

Also we are looking into KoenVosters' suggestion to run a timer job to export an XML file of all sites.  We believe that it may be faster (I emphasize may) to read the XML instead of hitting the SP server multiple times.  

In addition, we have created a new project on CodePlex called SharePoint 2010 My Links Web Part and will be releasing the source code once I've had it cleaned up and commented properly.

Thanks again for all your help.

Now, If I could only convince Microsoft that they should add a Sort function to the SPSite collections... (we had to manually sort the sites in alpha order :-( )
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now