I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.

I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. 

I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See DNN\Admin\Users\ManageUsers.ascx) that exists in a different directory altogether.

My issue is that when using the UI.UserControls.LabelControl,
the label and the help text will not display. I have set the control name property to a list box (for giggles, I tried a text box, but that didn't work). It has its runat="server" and the id declared inside of the ascx file is the same id used in the ascx.vb file. For thoroughness sake, I am posting the code i've used below:

In the ctrlCounty.ascx file:

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="ctrlCounty.ascx.vb" Inherits="OSDE.Wave.Controls.ctrlCounty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="dnn" TagName="label" Src="~/controls/labelControl.ascx" %>
<table width="80%" align="center" border="1">
 <tr align="center">
  <td align="right"><dnn:label id="plCountyDescriber" controlname="ddlCounty" runat="server"></dnn:label></td>
  <td align="left"><asp:dropdownlist id="ddlCounty" runat="server" AutoPostBack="true"></asp:dropdownlist>
   <asp:TextBox id="txtCounty" runat="server"></asp:TextBox></td>
 </tr>
</table>

In the ctrlCounty.ascx.vb file:

Protected WithEvents plCountyDescriber As UI.UserControls.LabelControl


In the ctrlCounty.ascx.resx file:

<?xml version="1.0" encoding="utf-8" ?>
<root>
 <!--
    Microsoft ResX Schema
   
    Version 1.3
   
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
   
    Example:
   
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">1.3</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1">this is my long string</data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        [base64 mime encoded serialized .NET Framework object]
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        [base64 mime encoded string representing a byte array form of the .NET Framework object]
    </data>
               
    There are any number of "resheader" rows that contain simple
    name/value pairs.
   
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
   
    The mimetype is used forserialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
   
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
   
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
   
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
 <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xsd:element name="root" msdata:IsDataSet="true">
   <xsd:complexType>
    <xsd:choice maxOccurs="unbounded">
     <xsd:element name="data">
      <xsd:complexType>
       <xsd:sequence>
        <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
        <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
       </xsd:sequence>
       <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
       <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
       <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
      </xsd:complexType>
     </xsd:element>
     <xsd:element name="resheader">
      <xsd:complexType>
       <xsd:sequence>
        <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
       </xsd:sequence>
       <xsd:attribute name="name" type="xsd:string" use="required" />
      </xsd:complexType>
     </xsd:element>
    </xsd:choice>
   </xsd:complexType>
  </xsd:element>
 </xsd:schema>
 <resheader name="resmimetype">
  <value>text/microsoft-resx</value>
 </resheader>
 <resheader name="version">
  <value>1.3</value>
 </resheader>
 <resheader name="reader">
  <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 </resheader>
 <resheader name="writer">
  <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 </resheader>
 <data name="$this.TrayAutoArrange" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <value>True</value>
 </data>
 <data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <value>False</value>
 </data>
 <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <value>Assembly</value>
 </data>
 <data name="plCountyDescriber.Text">
  <value>Select a county:</value>
 </data>
 <data name="plCountyDescriber.Help">
  <value>Select a county from the drop down list.</value>
 </data>
</root>

I have stared at the directory structure, code used, and anything else I can think of. It looks to me that I have my control set up exactly like DotNetNuke has its User control setup, save that their's works and mine does not. I am at a tremendous lost as to what I have done wrong. Please aid me in any way you can.

0
jbaisden
6/18/2005 1:12:36 AM
📁 asp.net.dotnetnuke
📃 25171 articles.
⭐ 0 followers.

💬 6 Replies
👁️‍🗨️ 1706 Views

In the plCountyDescriber tag, add the following property:

<dnn:label id="plCountyDescriber" controlname="ddlCounty" runat="server" resourcekey="plCountyDescriber"></dnn:label>

BTW, I should mention that you are using a standard asp:label, not a DotNetNuke label control, so the controlname won't do anything, and the .Help text also will not apply.

In order to use the DNN label control, add this line to the ascx file:
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

and then use the control like this:
<dnn:label id="plCountyDescriber" runat="server" controlname="ddlCounty" suffix=":" resourcekey="plCountyDescriber"></dnn:label>
-Todd Davis
http://www.SeaburyDesign.com
0
toddhd
6/18/2005 1:40:16 AM
I greatly appreciate your reply. I modified my ascx file to like: 

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="ctrlCounty.ascx.vb" Inherits="OSDE.Wave.Controls.ctrlCounty" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="dnn" TagName="label" Src="~/controls/labelControl.ascx" %>
<table width="80%" align="center" border="1">
 <tr align="center">
  <td align="right"><dnn:label id="plCountyDescriber"  controlname="ddlCounty" runat="server" suffix=":" resourceKey="plCountyDescriber" ></dnn:label></td>
  <td align="left"><asp:dropdownlist id="ddlCounty" runat="server" AutoPostBack="true"></asp:dropdownlist>
   <asp:TextBox id="txtCounty" runat="server"></asp:TextBox></td>
 </tr>
</table>


This still does not work, though. Any other ideas?
0
jbaisden
6/20/2005 12:42:42 PM
 jbaisden wrote:
Any other ideas?


Sure - let's hard code it, and do a little troubleshooting at the same time.

The resourcekey="" thing should work - if it isn't, then likely you don't have the *.resx file in the correct location. But ok, so let's do this - in the Page_Load() event (make this the first line in the function, before any postback checks, etc.) put this line:

plCountyDescriber.Text = Localization.GetString("plCountyDescriber", LocalResourceFile)

This will go out to the *.resx file, look for the string associated with plCountyDescriber.Text, and pull it in. If this does not work, then...

First, open up your *.resx file, and make sure that the data item exists, and looks like this:

<data name="plCountyDescriber.Text">

<value>County Describer</value>

</data>

Pay particluar attention to the case of the name="" value, it is case sensitive.

If that entry exists and looks kosher, then do this:

In the Page_Load() event, after the line above, do a simple:

Response.Write(LocalResourceFile)

Reload the page and look at the output at the very top of the page, it will display the path to the *.resx file. Make sure this is the correct path! To be honest with it - it IS the right path - if your *.resx file isn't there, it should be. But, you can also put any path you like, if you don't want to move it. i.e.:

plCountyDescriber.Text = Localization.GetString("plCountyDescriber", "/mystuff/my.resx")


-Todd Davis
http://www.SeaburyDesign.com
0
toddhd
6/20/2005 1:35:43 PM
I've had some whoppers in my time as a programmer (almost 2 years...yea i've been around real long...), but this takes the cake. I don't know what I changed or did not change. I tried your code todd and the directory printed out by the response stream was right on the money. I was actually hoping it wouldn't be. So then I added your code: 

plCountyDescriber.Text = Localization.GetString("plCountyDescriber", "/mystuff/my.resx")

but instead of "/mystuff/my.resx", I used the resource directory retrieved by

'Taken from dotnetnuke's user.ascx.vb file where MyFileName is a private string that is hardcoded
'with the filename.
Public
ReadOnly Property LocalResourceFile() As String
Get
Return Services.Localization.Localization.GetResourceFile(Me, MyFileName)
End Get
End Property

After doing this the control's text and help label's loaded. I thought, well, duh! of course it should load, I hard coded the bloody thing. So I remove the
plCountyDescriber.Text = Localization.GetString("plCountyDescriber", "/mystuff/my.resx")
and reload everything. Presto, the damn thing works. Honestly, it really shouldn't. I didn't change anything. The only theory I have is one borrowed from a co-worker that figured VS .Net was not re-loading the modified *.resx file that had the keys for this control. By adding this code, I force .Net to load the new file. When I removed the code, it had the file cached so it worked. It really doesn't make much sense to me as to how this issue occurred or if its just a whole bunch of bolony. No matter, though, it's working now.

Thank you so much for your help. I have easily spent 12 hours on this single issue. I have been dreading this morning as it seemed a bit dreary at this point. Alas, my hope rekindled.

Sincerely,

jbaisden

0
jbaisden
6/20/2005 2:29:23 PM
I'm glad you got it working. I miss the good old days when you fixed the TV by kicking it... hard... how do you code a kick?Big Smile [:D]
-Todd Davis
http://www.SeaburyDesign.com
0
toddhd
6/20/2005 2:49:49 PM
I ran into this same problem.  When once .ascx file loads another .ascx file.  In my case, the LocalResourceFile was incorrect!  It was actually pointing to the name of the control instance.  For instance, the control was named "ControlName.ascx", and registered on my page as TagName="ControlNameCtrl".  I had an instance of that control on my page where the Control Id was "ControlNameCtrl1" (which is the default name that VS gives you).

It just so happened that DNN points LocalResourceFile to "/DesktopModules/MyModule/App_Local/ControlNameCtrl1" which doesn't seem correct.  It would seem that it should point to name of the user control (ControlName.ascx) and not the instance of that Control (ControlNameCtrl1), because that would mean that you need 1 resource file for every instance???  I don't think so!  My fix was to hard code the LocalResourceFile to point to where I think that it should point.

Figured that I would post this just in case anyone else is struggling with it or I forget and hit it in the future! :)
0
jward1976
10/5/2005 1:24:00 AM
Reply: