1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Accentuated characters on a Custom Control

Accentuated characters on a Custom Control

4 posts, 0 answered
  1. Daniel
    Daniel avatar
    35 posts
    Registered:
    15 Jun 2010
    10 Sep 2010
    Link to this post
    Greetings,

    I'm having a small issue while attempting to use accentuated characters on a Custom Control.

    The .aspx file is defined as an Embedded Resource. If accentuated characters are applied directly on the .aspx as normal text they show up correctly, however if they are used in a property of any control (ie Text="") they will appear incorrectly. If they are set from the code-behind file, though, they also appear correctly.

    In order to reproduce this all that's needed is a Custom Control with the following files:

    Test.ascx (Embedded Resource)
    <%@ Control Language="C#"%>
     
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" %>
     
    <sitefinity:ResourceLinks ID="resourcesLinks" runat="server" UseEmbeddedThemes="True">
        <sitefinity:ResourceFile AssemblyInfo="Controls.Test.Test, Controls" Name="Controls.Test.Resources.Test.css" Static="true"/>
    </sitefinity:ResourceLinks>
     
    Normal Text: ãâáàº
    <br />
    ASPTextBox (Text="ãâáàº" applied on the .ASCX): <asp:TextBox ID="TextBox1" runat="server" Text="ãâáàº" />
    <br />
    RadTextBox (Text="ãâáàº" applied on the .ASCX): <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="ãâáàº" />
    <br />
    ASPTextBox (Text="ãâáàº" applied on the .CS): <asp:TextBox ID="TextBox2" runat="server" />
    <br />
    RadTextBox (Text="ãâáàº" applied on the .CS): <telerik:RadTextBox ID="RadTextBox2" runat="server" />

    Test.cs
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Web.UI;
    using Telerik.Sitefinity.Web.UI.ControlDesign;
    using Telerik.Sitefinity.Modules.Pages.Web.UI;
    using Telerik.Web.UI;
     
    namespace Controls.Test
    {
        [RequireScriptManager]
        [ControlDesigner(typeof(TestDesigner))]
        public class Test : CustomSimpleView
        {
            protected override void InitializeControls(GenericContainer controlContainer)
            {
                TextBox2.Text = "ãâáàº";
                RadTextBox2.Text = "ãâáàº";
            }
     
            protected override string LayoutTemplateName
            {
                get { return "Controls.Test.Views.Test.ascx"; }
            }
     
            protected virtual TextBox TextBox2
            {
                get { return base.Container.GetControl<TextBox>("TextBox2", true); }
            }
     
            protected virtual RadTextBox RadTextBox2
            {
                get { return base.Container.GetControl<RadTextBox>("RadTextBox2", true); }
            }
        }
    }

    The result is the one in the attached image. 

    Is there any solution for this issue?

    Regards,
    Daniel
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Sep 2010
    Link to this post
    Hello Daniel,

    Thank you for using our services.

    Can you please check what is the encoding of the .ascx files on your machine? By default it should be utf-8 which will present no problems with characters.

    You can also take an alternative approach to this - using resource classes, in the same way we use them for the text on all labels and messages in Sitefinity. What has to be done is to create a class which will hold all of your resource texts. This class should inherit from Telerik.Sitefinity.Localization.Resource. Then on the initialize event of your module (for which you are building control) you have to register the resource class. If you are not using a module but a stand alone control you should register this resource class separately. This register should be done in OnInit event of the control for now, we are changing this to allow you to register resource classes in initialization event of the system. This approach gives you the ability to change the labels' text or translate it for other cultures through the Sitefinity administrative UI. I am attaching a small sample code library to illustrate what should be done for a stand alone control. Note that the code in OnInit event of the control will be moved to a more appropriate event with the Sitefinity 4.0 Beta 2 release.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Oguz
    Oguz avatar
    10 posts
    Registered:
    01 Feb 2011
    10 Feb 2011
    Link to this post
    I am having the same issue with the current version of Sitefinity.
    I checked the file encodings, they are UTF-8.
    By the way, as Daniel reported before, the display problems occur for the text in attributes.
    Using the resource files approach still the only workaround for this?

    Thank you.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Feb 2011
    Link to this post
    Hi Oguz,

    Yes, you should apply this approach.

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered