Search code examples
javascripthtmlasciispecial-charactersglobalization

Change label text from .resx, issue with especial character


I'm trying to change the text property from a label dynamically. I get the new value from a .resx file, this new value contains the characters Nº, but it doesn't display correctly, instead Nº it displays N&#186. I tried some advises that I found here on the stackoverflow, like Resource file variable giving string ASCII code issues in js alert box

I also tried to use javascript encode/decode functions, but none of them worked. I'm spending a lot of time trying to fix it. Please, any help?

Its a MVC3 application. My code:

  novoLabel = "@Label.LblPares";

 $("label[for='Cabo_Pares']").text(novoLabel);

@Label.LblPares value is Nº de Pares and its displays to the user the value N&#186 de Pares

Thanks!


Solution

  • Try chaning text() to html():

    $("label[for='Cabo_Pares']").html(novoLabel);
    

    JSFiddle: http://jsfiddle.net/AWzSc/