web.config Resource Provider Configuration

The main configuration for wwDbResourceProvider is handled through web.config and the special wwDbResource Provider section.

<configuration> <configSections> <section name="wwDbResourceProvider" type="Westwind.Globalization.wwDbResourceProviderSection" requirePermission="false"/> </configSections> <wwDbResourceProvider connectionString="server=(local);database=YourDatabase;integrated security=true;AjaxAspNet" resourceTableName="Localizations_Padnug" designTimeVirtualPath="/internationalization" showLocalizationControlOptions="true" showControlIcons="true" localizationFormWebPath="~/localizationadmin/localizeform.aspx" addMissingResources="false" useVsNetResourceNaming="false" stronglyTypedGlobalResource="~/App_Code/Resources.cs,AppResources" /> </configuration>

You need to add a new Config Section header in the configSections area and then actually provide the configuration section.

In addition you need to also enable the provider in the globalization section:

<system.web> <globalization resourceProviderFactoryType="Westwind.Globalization.wwDbResourceProviderFactory,Westwind.Globalization" /> <!-- <globalization resourceProviderFactoryType="Westwind.Globalization.wwDbSimpleResourceProviderFactory,Westwind.Globalization" /> --> </system.web>

Do not enable the Resource Provider until you have created the resource table and imported resources from any .Resx files you may have used for localization while running with the stock Resx provider. If you don't do this all your resources will render blank for any localized content including the resource administration form.

To start run the Admin LocalizeForm.aspx. If the resource table doesn't exist, create it. Once the table exists go ahead and import the .Resx resources. Once you have resource data in the admin UI you know the provider is properly configured and you can go ahead and enable the provider.

Two Providers

Note that this library ships with two providers, wwDbResourceProvider and wwDbSimpleResourceProvider. The full wwDbResourceProvider implements both a ResourceProvider and ResourceManager so it can be used both in Web, Windows and library projects. wwDbSimpleResourceProvider is an ASP.NET only implementation that foregoes the ResourceManager implementation and directly accesses the data components which results in a better performing interface (roughly 1.5-2% faster). Both providers behave identically and use the underlying data and configuration interfaces but the resource manager interfaces uses both the ResourceProvider interface as well as the ResourceManager interface to feed that data which creates the extra overhead.

wwDbResourceProvider Configuration Settings

The resource provider is configured via the wwDbResourceProvider configuration settings. These settings are used both at runtime and at design time so it's important that this section is set up appropriately as soon as you enable the resource provider.

Most of the settings are fairly self explanatory and you can review them in detail in the wwDbResourceConfiguration class docs.

The connection string to the database where the Resource Table will be used. You can use an existing database or create a new database. Note that the provider can create a Resource table and if you want to use this option the account for the connection needs rights to create a table. Besides that resource admnistration requires read/write/update/delete access to the table.

This is the most important key that determines the name of a SQL Server database that the data is stored in. This string can be a full connection string or a key value from the .Config ConnectionStrings sections.

The name of the resource table. The default is Localizations.

This is the virtual path of your Web Application as seen by Visual Studio. This path is used for the Generate Local Resources option in the Visual Studio Web Form designer. The path is used to strip off the virtual path for each page. Make sure you get the virtual path correct or your resource names will get screwed up. If you see full paths that start with a / for ResourceSet names you know your virtual path is incorrect.

Determines whether the wwDbDataResourceControl shows on pages that it's been placed on. This option is basically a global switch that enables this control. When the switch is set the control shows, otherwise it doesn't which is useful in order to switch the site in and out of Resource editing mode.

Determines whether a page that shows the above control shows icons for each of the localizable resources on the page. Note that icons are shown only next to controls that are marked as [Localizable] (either by your own controls or by stock ASP.NET controls). Some localizable properties (like GridView Columns for example) won't show up however, because they are not controls although they may be marked as implict resources.

This is the path to the LocalizeForm.aspx that is shipped with the provider. This form provides the interactive Web interface for Resource Localization and you must copy this page into your Web application (preferrably into a separate directory) and then provide a path to it. The wwDbResourceControl uses this URL to find the administration form and bring it up for resource editing.

If true adds any missing resources into the database automatically as empty entries for the invariant language.

If true uses Implicit Resource naming the way Visual Studio does which includes a ResourceX postfix to each assigned control. The default for this provider is to use the control name as the resource key if possible and only add a counter if there's duplication, which makes for much more readable resource names.

When this value is not blank exporting resources to .ResX files causes a strongly typed resource file to be created. This file properly works with ASP.NET's GetLocal/GlobalResourceObject rather than the stock resources created by Visual Studio (which is very ineffcient). You can also separately generate these resources with GenerateStronglyTypedResources.aspx page in the admin folder. The value is specified as a virtual path to the source file (use .cs or .vb to identify language) and a namespace to generate (for example: ~/App_Code/Resources.cs, AppResources).

  Last Updated: 7/16/2007 | © West Wind Technologies, 2008