Retrieves a localized string based on a System.Web.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.
- attributeName
- The System.Web.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 null, and a localized value is not found; otherwise, false.
A string representing the localized attribute.
The SiteMapNode.GetExplicitResourceString(string, string, bool) method is invoked in the get accessor of the SiteMapNode.Title property, the SiteMapNode.Description property, and any custom attributes that are defined in the SiteMapNode.Attributes property. The System.Web.SiteMapProvider object by which the System.Web.SiteMapNode is tracked must have its SiteMapProvider.EnableLocalization property set to true for the SiteMapNode.GetExplicitResourceString(string, string, bool) method to return a localized string. If the SiteMapProvider.EnableLocalization is set to false, localization is not performed and the SiteMapNode.GetExplicitResourceString(string, string, bool) method is never called.
The SiteMapNode.Title property, the SiteMapNode.Description property, and any custom attributes that are defined in the SiteMapNode.Attributes property first invoke the SiteMapNode.GetImplicitResourceString(string) method. If it returns null, the SiteMapNode.GetExplicitResourceString(string, string, bool) 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.
The System.Web.XmlSiteMapProvider class imposes the restriction that the System.Web.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 SiteMapNode.GetExplicitResourceString(string, string, bool) method uses the System.Collections.Specialized.NameValueCollection collection of resource keys that the System.Web.SiteMapNode object was initialized with. If a collection of resource keys was not specified, the SiteMapNode.GetExplicitResourceString(string, string, bool) returns null.