How do I write an HTML object in a text element in ASP.NET?

I need to write a submit button in ASP.NET so that the text value of the button is HTML encoded using the appropriate HTML entities for different French accented characters.

The button is simply declared as

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

      

If I am something like

button1.text = "Test é"

      

then it correctly renders the button text like Test é on the web page, but the HTML source is also Test é , which is not what I need - I need something different; or & # 233 ;.

If I am something like

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

      

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

How to solve this problem?

+2


a source to share


1 answer


You should be able to set text without encoding. You can try to set the globalization option in web.config inside system.web like this (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" />

      

+1


a source







All Articles