SiteMapNode.GetExplicitResourceString Method

Note: This method is new in the .NET Framework version 2.0.

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
)
protected String GetExplicitResourceString (
	String attributeName, 
	String defaultValue, 
	boolean throwIfNotFound
)
protected function GetExplicitResourceString (
	attributeName : String, 
	defaultValue : String, 
	throwIfNotFound : boolean
) : String

Parameters

attributeName

The SiteMapNode attribute to localize.

defaultValue

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

throwIfNotFound

true to throw an InvalidOperationException, if an explicit resource is defined for attributeName, defaultValue is a null reference (Nothing in Visual Basic), and a localized value is not found; otherwise, false.

Return Value

A string representing the localized attribute.

Exception typeCondition

ArgumentNullException

attributeName is a null reference (Nothing in Visual Basic).

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 a null reference (Nothing in Visual Basic), 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 a resource key that is the information for construction implicit resource expressions and explicit resource expressions defined for various 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 a null reference (Nothing in Visual Basic).

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: