I’m using explicit localization in my pages, like in:
<asp:Literal ID="appTitle" runat="server" Text="<%$ Resources:TranslationResource, AppTitle %>"></asp:Literal></div>
If the AppTitle resource does not exist, is there any way to avoid “parser error” and to show a empty string or the resource name?
Thanks in advance.
You could use
GetGlobalResourceObject, which does the same thing but returns null, rather than throwing an exception, if the key does not exist.You can easily add a fallback value using the null-coalescing operator:
If you need to modify the behavior of the localization provider in a centralized way (without needing to modify the syntax used in the pages), you can override
resourceProviderFactoryType. Add the type to the web.config globalization section …And create
MyLocalizationProviderby sub-classingResourceProviderFactory.