SPUserResource.Name Property

Gets the name of the user resource.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public ReadOnly Property Name As String
    Get
'Usage
Dim instance As SPUserResource
Dim value As String

value = instance.Name
public string Name { get; }

Property Value

Type: System.String
A string that contains the name of the resource.

Remarks

The following table contains keys to the names of resources used by localizable objects in SharePoint Foundation. Note that all of the names start with an underscore character and therefore cannot be used with SPUserResource class constructors.

Name starts with

Used by

_CTDesc

SPContentType.DescriptionResource

_CTName

SPContentType.NameResource

_FieldDesc

SPField.DescriptionResource

_FieldTitle

SPField.TitleResource

_ListDescription

SPList.DescriptionResource

_ListTitle

SPList.TitleResource

_NavNode

SPNavigationNode.TitleResource

_WebDescription

SPWeb.DescriptionResource

_WebTitle

SPWeb.TitleResource

In addition, the SPUserCustomAction class has three named resources whose names end with well-known strings.

Name ends with

Used by

_CUIExtension

SPUserCustomAction.CommandUIExtensionResource

_Description

SPUserCustomAction.DescriptionResource

_Title

SPUserCustomAction.TitleResource

Examples

The following example is a console application that prints the names of user resources associated with a list.

using System;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list = web.Lists.TryGetList("My Custom List");
                    if (list != null)
                    {
                        string formatString = "Resource name: {0}";

                        Console.WriteLine(formatString, list.DescriptionResource.Name);
                        Console.WriteLine(formatString, list.TitleResource.Name);
                        Console.WriteLine();

                        foreach (SPUserResource resource in list.UserResources)
                            Console.WriteLine(formatString, resource.Name);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("http://localhost")
            Using web As SPWeb = site.OpenWeb()

                Dim list As SPList = web.Lists.TryGetList("My Custom List")
                If list IsNot Nothing Then
                    Dim formatString As String = "Resource name: {0}"

                    Console.WriteLine(formatString, list.DescriptionResource.Name)
                    Console.WriteLine(formatString, list.TitleResource.Name)
                    Console.WriteLine()

                    For Each resource As SPUserResource In list.UserResources
                        Console.WriteLine(formatString, resource.Name)
                    Next
                End If

            End Using
        End Using
        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

The application produces the following output to the console:

Resource name: _ListDescription
Resource name: _ListTitle

Resource name: _CTDesc0x01000F66CDF312EED545AB5D6B13978DF8FD002104CB5F4FE5474285C6FF6EE164F636
Resource name: _CTName0x01000F66CDF312EED545AB5D6B13978DF8FD002104CB5F4FE5474285C6FF6EE164F636
Resource name: _FieldDescMy_x0020_Custom_x0020_Column
Resource name: _FieldTitleMy_x0020_Custom_x0020_Column
Resource name: _ListDescription
Resource name: _ListTitle

Press ENTER to continue....

See Also

Reference

SPUserResource Class

SPUserResource Members

Microsoft.SharePoint Namespace