Share via


SPUserResource.Value Property

Gets or sets the value of the resource for the thread's culture.

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

Syntax

'Declaration
Public Property Value As String
    Get
    Set
'Usage
Dim instance As SPUserResource
Dim value As String

value = instance.Value

instance.Value = value
public string Value { get; set; }

Property Value

Type: System.String
A string that contains the value for the CurrentUICulture property of the current thread. If the resource has not been translated for that culture, or if that culture is not supported by the Web site, the value for the Web site's default culture is used.

Examples

The following example is a console application that demonstrates how the value of the Value property can change depending on the culture of the current thread. The application enumerates the list of cultures supported by a Web site, sets the thread's CurrentUICulture to each supported culture, and prints the value of the user resource for the title of the Announcements list in the language of the thread's CurrentUICulture.

using System;
using System.Globalization;
using System.Threading;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list = web.Lists.TryGetList("Announcements");
                    if (list != null)
                    {
                        SPUserResource resource = list.TitleResource;
                        foreach (CultureInfo culture in web.SupportedUICultures)
                        {
                            Thread.CurrentThread.CurrentUICulture = culture;
                            Console.WriteLine("{0}: {1}", culture.Name, resource.Value);
                        }
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports System.Globalization
Imports System.Threading
Imports Microsoft.SharePoint

Module ConsoleApp

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

                Dim list As SPList = web.Lists.TryGetList("Announcements")
                If list IsNot Nothing Then

                    Dim resource As SPUserResource = list.TitleResource

                    For Each culture As CultureInfo In web.SupportedUICultures
                        Thread.CurrentThread.CurrentUICulture = culture
                        Console.WriteLine("{0}: {1}", culture.Name, resource.Value)
                    Next

                End If

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

End Module

See Also

Reference

SPUserResource Class

SPUserResource Members

Microsoft.SharePoint Namespace

GetValueForUICulture(CultureInfo)

SetValueForUICulture(CultureInfo, String)