Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Indicates whether the value of the Url property is a Uniform Resource Locator (URL) to a list.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public ReadOnly Property IsUrlToList As Boolean
Get
'Usage
Dim instance As SPContentTypeUsage
Dim value As Boolean
value = instance.IsUrlToList
public bool IsUrlToList { get; }
Property Value
Type: System.Boolean
true if the Url property contains a server-relative URL to the root folder of a list; otherwise, false.
Remarks
The value of this property can help you interpret the value of the Url property. For site content types, the Url property returns a server-relative URL for the Web site. For list content types, the Url property returns a server-relative URL for the root folder of the list.
Examples
The following example shows a console application that gets the usage collection for the built-in content type Folder. For each item in the collection, the application determines if the value of the Url property is for a list or for a site, and then prints that information, along with the URL, to the console.
Imports System
Imports System.Collections.Generic
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using siteCollection As SPSite = New SPSite("https://localhost")
Using rootWeb As SPWeb = siteCollection.RootWeb
' Get the content type.
Dim contentType As SPContentType = _
rootWeb.AvailableContentTypes(SPBuiltInContentTypeId.Folder)
' Get the usage collection.
Dim usages As IList(Of SPContentTypeUsage) = _
SPContentTypeUsage.GetUsages(contentType)
For Each usage As SPContentTypeUsage In usages
Console.WriteLine(vbCrLf + "{0} content type", _
IIf(usage.IsUrlToList, "List", "Site"))
Console.WriteLine("URL: {0}", usage.Url)
Next usage
End Using
End Using
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite siteCollection = new SPSite("https://localhost"))
{
using (SPWeb rootWeb = siteCollection.RootWeb)
{
// Get the content type.
SPContentType contentType =
rootWeb.AvailableContentTypes[SPBuiltInContentTypeId.Folder];
//Get the usage collection.
IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(contentType);
foreach (SPContentTypeUsage usage in usages)
{
Console.WriteLine("\n{0} content type.", usage.IsUrlToList ? "List" : "Site");
Console.WriteLine("URL: {0}", usage.Url);
}
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}
When the application is run against a very modest Web site, it prints the following output to the console.
Site content type.
URL: /
Site content type.
URL: /
List content type.
URL: /Lists/Links
List content type.
URL: /Lists/Tasks
List content type.
URL: /Lists/Announcements
List content type.
URL: /Lists/Reporting Metadata
List content type.
URL: /_catalogs/masterpage
List content type.
URL: /Shared Documents
List content type.
URL: /Reporting Templates
List content type.
URL: /Lists/Team Discussion
Press ENTER to continue...
See Also
Reference
Microsoft.SharePoint Namespace