user933
user933

Reputation: 69

How do I write an HTML entity in button text in ASP.NET?

I need to write out a submit button in ASP.NET so that the button text value is HTML-encoded using the proper HTML entities for the various French characters with accents.

The button is simply declared as

<asp:Button id="button1" runat="server" />

If I do something like

button1.text = "Test é"

then it displays the button text correctly as Test é in the web page, but the HTML source is also Test é, which is not what I need -- I need either &eacute; or &#233;.

If I do something like

button1.text = server.htmlencode("Test é") 

then it displays Test &#233; in the button text, i.e. Test &amp;#233; in the HTML source.

How do i solve this problem?

Upvotes: 2

Views: 1293

Answers (1)

thiagoleite
thiagoleite

Reputation: 503

You should be able to set the text without encoding anything. You can try to set globalization setting in web.config inside system.web as follows(Not sure if ISO-8859-1 is the correct encoding for french):

<globalization uiCulture="fr-FR" culture="fr-FR" enableClientBasedCulture="true"  responseEncoding="ISO-8859-1" fileEncoding="ISO-8859-1" />

Upvotes: 1

Related Questions