SPUtility.GetSPListFromName Method (SPWeb, Guid, String, String, String)
Retrieves the specified SharePoint list without specifying the associated SPContext object.
Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Shared Function GetSPListFromName ( _
web As SPWeb, _
webId As Guid, _
listGuid As String, _
listUrl As String, _
listDisplayName As String _
) As SPList
'Usage
Dim web As SPWeb
Dim webId As Guid
Dim listGuid As String
Dim listUrl As String
Dim listDisplayName As String
Dim returnValue As SPList
returnValue = SPUtility.GetSPListFromName(web, _
webId, listGuid, listUrl, listDisplayName)
public static SPList GetSPListFromName(
SPWeb web,
Guid webId,
string listGuid,
string listUrl,
string listDisplayName
)
Parameters
web
Type: Microsoft.SharePoint.SPWebAn SPWeb object that represents the SharePoint Web site to which the list belongs.
webId
Type: System.GuidThe globally unique identifier (GUID) of the SharePoint Web site to which the list belongs.
listGuid
Type: System.StringA string that provides the globally unique identifier (GUID) of the list.
listUrl
Type: System.StringA string that provides the URL of the list.
listDisplayName
Type: System.StringA string that provides the display name of the list.
Return Value
Type: Microsoft.SharePoint.SPList
The SharePoint list associated with the provided parameters. If the list does not exist or cannot be found using the supplied parameters, the method returns a null reference (Nothing in Visual Basic).
Remarks
One or more parameters of the GetSPListFromName method can be null or empty strings. The method first tests the values of the webId and listGuid parameters. If those values are null or empty, the method tests the value specified in the listUrl parameter. If that value is null or empty, the method uses the value in the listDisplayName parameter as a last resort.