문제

I have a list of elements, and one of those elements field is a string value that contains an spanish-accented text which I see ok in the list. Once I enter de Detail page for one of those elements, the accents are shown like this ó

I have a string variable that contains the original Spanish-Accented text, and I assign that value to the new view. Example:

string a = "facturación";

view.Document = a;

and the field a of the class view is declared like this:

string Document { get; set; }

when I do a quickwatch over "a" I see "facturación".

when I do a quickwatch over "view.Document" y see "facturación"

what can I do?

Thanks in advance!

도움이 되었습니까?

해결책

Found the error! The property was re-defined like this:

public string Document
  {
    get
    {
      return HttpUtility.HtmlEncode(txtDocument.Text);
    }
    set
    {
      txtDocument.Text = HttpUtility.HtmlEncode(value);
    }
  }

So the HtmlEncoding was the thing that was messing up with my string.

Thanks anyway!

다른 팁

The reason this happens is that the view is escaping the string before rendering it. Use <%= Server.HtmlDecode(mystring) %> in your view to render the string un-escaped.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top