This is a post concerning reading local resource file values or strings in .aspx and .ascx files in DotNetNuke 4.x.x.

The Problem

I tried to use GetLocalResourceObject (which works fine in normal Asp.Net), but in this DotNetNuke module I got the exception:

The resource class for this page was not found. Please check if the resource file exists and try again.

The reason for this seems to be these lines in web.config which are due to DotNetNuke:

<buildProviders>
<remove extension=".resx"/>
<remove extension=".resources"/>
</buildProviders>

Currently I don’t know exactly why this causes the problem, but it seems to be it.

The Solution

In DotNetNuke always get resources programmatically like this:

<span style="color: #006600;">Localization.GetString("mycontrol.Text", LocalResourceFile)</span>

The regular (Asp.Net 2.0) way of doing it does not work:

<span style="color: #990000;">GetLocalResourceObject("mycontrol.Text")</span> //does not work
Advertisements