Reputation: 27464
I'm trying to set asp:image AlternateText. The string I want to set it to contains HTML entities that are already escaped. But asp.net then escapes them again.
I'm setting it with a simple assignment statement. Basically:
imgBanner.AlternateText="José"
But what I get in the source is actually
<img blah blah alt="Jos&eacute;">
Which of course then displays as "José" rather than showing the accented "e".
Really the text is coming from a function that reads it from the database, but I can watch in the debugger and see that the text is correct when I read it from the DB, and if I examine the contents of AlternateText immediately after the assignment it is correct. But when it gets to the browser, it's all been double-escaped.
(P.S. No need to warn me about script injection attacks. The text in the database is entered by me. There is no way for a user to update this table. The reason for getting it from the DB is because I read different text depending on the language and other parameters.)
Upvotes: 2
Views: 258
Reputation: 1086
Try
imgBanner.AlternateText = HttpUtility.HtmlDecode("José")
Upvotes: 2