Export (0) Print
Expand All

SiteMapNode.GetExplicitResourceString Method

Retrieves a localized string based on a SiteMapNode attribute to localize, a default string to return if no resource is found, and a Boolean value indicating whether to throw an exception if no resource is found.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

protected string GetExplicitResourceString(
	string attributeName,
	string defaultValue,
	bool throwIfNotFound
)

Parameters

attributeName
Type: System.String

The SiteMapNode attribute to localize.

defaultValue
Type: System.String

The default value to return if a matching resource is not found.

throwIfNotFound
Type: System.Boolean

true to throw an InvalidOperationException, if an explicit resource is defined for attributeName, defaultValue is null, and a localized value is not found; otherwise, false.

Return Value

Type: System.String
A string representing the localized attribute.

ExceptionCondition
ArgumentNullException

attributeName is null.

InvalidOperationException

A matching resource object was not found and throwIfNotFound is true.

The GetExplicitResourceString method is invoked in the get accessor of the Title property, the Description property, and any custom attributes that are defined in the Attributes property. The SiteMapProvider object by which the SiteMapNode is tracked must have its EnableLocalization property set to true for the GetExplicitResourceString method to return a localized string. If the EnableLocalization is set to false, localization is not performed and the GetExplicitResourceString method is never called.

The Title property, the Description property, and any custom attributes that are defined in the Attributes property first invoke the GetImplicitResourceString method. If it returns null, the GetExplicitResourceString method is invoked with defaultValue set to the value of the default value from the explicit resource expression (assuming one was defined) and throwIfNotFound set to true.

NoteNote

The XmlSiteMapProvider class imposes the restriction that the SiteMapNode object cannot define both implicit resource expressions and explicit resource expressions for attributes. However, a custom provider implementation can choose to allow both.

The GetExplicitResourceString method uses the NameValueCollection collection of resource keys that the SiteMapNode object was initialized with. If a collection of resource keys was not specified, the GetExplicitResourceString returns null.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft