Errors rendering an html page

M

Manuel

Hi,

When I load an html page (greek language) inside a span id="DivHtml" my
website stops working correctly or the inner html page is rendered using
invalid chars. When I load other html pages (english or italian) it works.
The "greek" html page is rendered correctly if opened outside the application

Thank you very much
Manuel

Code Example:

DivHtml.InnerHtml = s.ToString();
(s is a stringbuilder containing the html)

<asp:panel runat="server" ID="PanelHtml" BorderStyle="Groove"
ScrollBars="Vertical" Width="100%" >
<span id="DivHtml" runat="server"></span>
</asp:panel>
 
T

ThatsIT.net.au

just a guess

try

s = HttpUtility.HtmlEncode( s.ToString())

DivHtml.InnerHtml = s.ToString();
 
T

Thomas Sun [MSFT]

Hi,

From your description, I understand that when you request your website you
get the invalid characters on page, but the character shows correctly when
you request another website on internet. If I have misunderstood you,
please feel free to let me know.

Did you specify the character set or the encoding for your website? If not,
please set Unicode encoding in your ASP.NET website. You can try to use
UTF-8 encoding, which allows you to create multilingual Web content without
having to change the encoding based on the target language.

For ASP.NET website, we can specify it in your web.config:
===========================
<globalization requestEncoding=" UTF-8 " responseEncoding=" UTF-8 " />
===========================

For more information about globalization Element, please see#
http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx


I look forward to receiving your test results.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
M

Manuel

Hi,

I've tried to add the globalization requestEncoding in the web.config but
the behaviour is the same.
It happens only embedding a particular html page.
Can I send it to you via email ?

Thank you very much

Manuel
 
T

Thomas Sun [MSFT]

Hi Manuel,

Thanks for your response.

Since you are specifying the string in code behind class, you can use
UTF8Encoding Class to convert the string. For more information, see #
http://msdn.microsoft.com/en-us/library/system.text.utf8encoding.aspx

Yes, you can send me a simplified package that can repro the error on your
machine. My email is (e-mail address removed).

I look forward to hearing from you.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support
 
M

Manuel

Hi Thomas,

looking at the HTML page that I need to embed I've found:
<META http-equiv=Content-Type content="text/html; charset=iso-8859-7">

So if I write:
StreamReader sr = new StreamReader(fileName,
Encoding.GetEncoding("iso-8859-7"));
string s = sr.ReadToEnd();
sr.Close();

DivHtml.InnerHtml = s;

works correctly.

Thank you very much for your help !
Manuel
 
T

Thomas Sun [MSFT]

Hi Manuel,

Thanks for your response and I am glad that you resolved it.

If you have any farther question, please feel free to post it here.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top