質問

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