New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedLocalization in ascx codeLocalization in ascx code
New Post
11/16/2014 3:45 PM

I'm starting module developing and I'm facing two issue.

First one is using Christoc template. It seems that trying to use <% = Localize("string") %> in the ascx code doesn't work, while using it in the code behind for that same control works. This may make some sense in that the function is defined in the base class this control inherits from (well there is a little base class chain involved really PortalModuleBase > MyModuleBase > ActualControl
So maybe while code behind "knows" where the control inherits from, the ascx part of the code doesn't. I tried with CodeFileBaseClass attribute in the control declaration, setting it to MyModuleBase, but that didn't work as well. Any hint to use the properties and function of PortalModuleBase directly in my ascx code?

Second issue is a curious one. I'm trying to set my module dev myself, without the template, without packaging and any bonus stuff already in there. A bare bone module development. The strange thing is that.. I reference the DotNetNuke.dll but when in the project properties I set the directories for the Servers to and then override for the base application to I got this error in the control definition (ascx code part) which gets green underlined in visualstudio "Namespace or type defined in the imports "DotNetNuke.UI' doesn't contain any public member or cannot be found..."

If instead I switch the server in project property to use visual studio development server, everything works BUT of course I cannot reference dnn root with ~ for adding dnn controls in the ascx code.

Odd thing this doesn't happen with Christoc template which correctly uses IIS, but I copied the very same settings in my bare bone project.

New Post
11/17/2014 4:03 AM

Hi Max,

To localize string in *.ascx file, please test this code:

<%= Localization.GetString("KeyFromResxFile", Me.LocalResourceFile) %>

I'm assuming that in View.ascx.resx file is something like:

KeyFromResxFile.Text - "My localized value"


New Post
11/17/2014 5:11 PM
Hallo Barry, thank you for your reply.
I tried but this, just like <% = Localize("string") %> your code is not understood ("Localization is not declared or it may be inaccessible due to its protection level") in ascx code part (while is working fine in the code behind). It seems like the ascx code part is not aware of the base class inheritance from PortalModuleBase.
New Post
11/18/2014 2:17 AM

in ascx file try this:

DotNetNuke.Services.Localization.Localization.GetString("KeyFromResxFile", this.LocalResourceFile)

or edit file *.csproj and add line: <Import Include="DotNetNuke.Services.Localization" /> in section where are entries "<Import Include=...." 

I'm assuming that you using C#

New Post
11/18/2014 8:56 AM
this.LocalResourceFile won't work for the same reason that inheritance from base class doesn't seem to be available in ascx code. So will not work thing like this.PortalId od this.ModuleId and everything derived from PortalModuleBase (everything works fine in code behind of course).

Anyway if I try with DotNetNuke.Services.Localization prefix in ascx I have the message (DotNetNuke is not declared and so on...) and nothing changes if I add <%@ Import Namespace="DotNetNuke.Services.Localization" %>
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedLocalization in ascx codeLocalization in ascx code

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out