Accentuated characters on a Custom Control

Posted by Community Admin on 03-Aug-2018 11:37

Accentuated characters on a Custom Control

All Replies

Posted by Community Admin on 10-Sep-2010 00:00
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
Posted by Community Admin on 13-Sep-2010 00:00
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
Posted by Community Admin on 10-Feb-2011 00:00
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.
Posted by Community Admin on 15-Feb-2011 00:00
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
This thread is closed