Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Title encoding

Not answered Title encoding

Feed from this thread
  • Jacques avatar

    Posted on Oct 4, 2011 (permalink)

    How can Window title be set to accept utf-8 encoding?

    The following show how Telerik Window is used. The action 'Edit' in controller 'Adresse' renders a partial view of an address.
    After loading, the character 'à' is not redered properly in the Window's title bar.

    @(Html.Telerik().Window()
        .Name("Window")
        .Title("Adresse à modifier")
        .Buttons(b => b.Maximize().Close())
        .Visible(false)
        .Modal(true)
        .Width(500)
        .Height(310)
    )
     
     
    @(Html.Telerik().Grid(Model)
        .Name("Grid")
        //.ToolBar(commands => commands.Insert())
        .ToolBar(commands => commands.Template(
            @<text>
                <input type='button' value='Ajouter un contenu' onclick="insertRecord()" />
            </text>
        ))
    ....//removed for brievety
            columns.Template(
                @<text>
                    <input type="button" value="Editer" onclick="updateRecord('@item.ID')" />
                    <input type="button" value="Enlever" onclick="deleteRecord('@item.ID')" />
                </text>
            ).Width(150);
        })
    ....//removed for brievety
    )
    <script type="text/javascript">
        function insertRecord() {
            var url = '@Url.Action("Edit", "Adresse")';
            $.post(url, {}, function (data) {
                var window = $('#Window').data('tWindow');
                window.title("Nouvelle adresse");
                window.open();
                window.content(data);
            });
        }
        function updateRecord(id) {
            var url = '@Url.Action("Edit", "Adresse")';
            $.post(url, {}, function (data) {
                var window = $('#Window').data('tWindow');
                window.title("Adresse à modifier");
                window.open();
                window.content(data);
            });
        }


    I have tried the following without any success. Can you help resolve this issue?
    Thanks

    function updateRecord(id) {
        var url = '@Url.Action("Edit", "Adresse")';
        $.ajax({
            type: 'POST',
            url: url,
            data: { id: id },
            success: function (data) {
                var window = $('#Window').data('tWindow');
                window.title("Adresse à modifier");
                window.content(data);
                window.open();
            },
            scriptCharset: "utf-8",
            contentType: "text/html; charset=utf-8"
        });
    }

    Reply

  • Adam avatar

    Posted on Feb 10, 2012 (permalink)

    Hoping this can be resolved without a hack soon

    In the window title I get "Iniciar sesi&#243;n" instead of "Iniciar sesión"

    Can be resolved with a hack:

    @Html.Telerik().Window().Name("WindowName").Title(Html.Raw(Resources.LabelLogin).ToHtmlString())


    or in javascript:

    var window = $("#WindowName").data("tWindow");
    window.title('@Html.Raw(Resources.LabelLogin)');

    Reply

  • Alex Gyoshev Alex Gyoshev avatar

    Posted on Feb 15, 2012 (permalink)

    The window title should accept the strings, if the page itself is utf-8 encoded. In particular, the window in the online demos can accept the utf-8 strings if you set them through the javascript console. Using ToHtmlString encodes the characters as entities, therefore the hack works. Can you please verify that the pages are utf-8 encoded?

    All the best,
    Alex Gyoshev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Adam avatar

    Posted on Feb 15, 2012 (permalink)

    Thanks for the response Alex,

    My layout page defines utf-8 encoding:

    <head>
        <meta charset="utf-8" />
        ...
    </head>

    The view with the telerik window is a partial view, rendered in the layout page using @Html.Action(), but I don't think that should make a difference. Below is the window defined in my partial view. I actually discovered that I didn't need to do the ToHtmlString() call; it was the window content partial view causing the problem.

    Html.Telerik().Window()
                    .Name("AuthenticationWindow")
                    .Modal(true)
                    .Title(Resources.LabelLogin)
                    .LoadContentFrom("LoginForm", "Authentication")
                    .Render();

    So far everything works. My window content is another partial view. In that partial view I have a $(document).ready() handler which sets the window title for whichever form gets loaded into the window content:

    $(document).ready(function () {
            var window = $("#AuthenticationWindow").data("tWindow");
            if (window != null) {
                window.title('@Resources.LabelLogin');
            }
    }

    This is where the problem occurs. If I comment out the javascript line to change the title it is fine (or if I wrap it in Html.Raw()). However, I replace the window content later on with different forms, so I need to change the window title in javascript. Somehow, the window content isn't utf-8 encoded or I am doing something wrong I guess.

    Reply

  • Alex Gyoshev Alex Gyoshev avatar

    Posted on Feb 16, 2012 (permalink)

    Hello Adam,

    Please ensure that your page is served (and saved) with the proper encoding. You can inspect that in the network tab of the chrome developer tools or the net tab in firebug. Refer to the attached project for a demo that shows that the window itself does not encode the content.

    Kind regards,
    Alex Gyoshev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
    Attached files

    Reply

  • Adam avatar

    Posted on Mar 1, 2012 (permalink)

    Excuse the late reply,

    I did verify in the browser that the request has UTF-8 encoding so I am not sure what would be causing the issue.

    Reply

  • Dimo Dimo admin's avatar

    Posted on Mar 2, 2012 (permalink)

    Hi Adam,

    Did you try the attached sample application, which shows how UTF-8 characters work in the Window title? If you have troubles with it, then the problem must be in the browser settings or wrong encoding headers sent by the web server.

    Kind regards,
    Dimo
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Title encoding
Related resources for "Title encoding"

ASP.NET MVC Window Features  |  Documentation  |  Demos  |  Telerik TV ]