Solved

Expandable list of URLs

Posted on 2013-01-11
7
510 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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