Solved

Expandable list of URLs

Posted on 2013-01-11
7
498 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short film showing how OnPage and Connectwise integration works.

911 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

20 Experts available now in Live!

Get 1:1 Help Now