Last post May 11, 2011 12:14 PM by losbear
May 11, 2011 12:14 PM|losbear|LINK
I'm posting this problem/solution so that anyone else that encounters this problem doesn't spend days investigating, like I did.
I created a solution that loads an XML document into a dataset and loops through and prints the content in the XML into a literalcontrol, like this:
'load xml into dataset
. . .
'each row in the dataset adds to a placeholder
'part of XML that was causing this problem (slightly modified, of course).
<content><![CDATA[ this is some text<br /><br />Punjabi text: ਹਾੰ,
ਬਿਲਕੁਲ ਸਚ ਬੋਲਾੰਗਾ <br><br>More html text. ]]></content>
I tested it and released it, but then started getting complaints from some users that this page was loading, but then immediately displaying blank. All the complaints were coming from IE users (IE8, in particular, but some were using IE9). I loaded it and
it was working fine for me. I tried it on Firefox and Chrome, still worked fine.
I then tried it on one of my company's workstations and then it happened! I wasn't sure if it was global policy settings set by our Corporate team or if it was something the workstation had installed, but I tore that workstation apart trying to figure out
why it worked on my dev box, but not the workstation I was using to replicate the error. I googled for days and tried
- Clearing browser cache, no luck
- Disabling addons, no luck
- Using IE's builtin DEV Tools, but there were no errors.
- Thinking it was a memory issue, disable non-critical services, and ONLY have IE open, no luck
- Tried every variation of permissions on IE and security groups
I did find that opening up DEV tools (F12) and then changing the compatibility mode to IE7 allowed it to load and work correctly, but I couldn't expect every one of my IE users to do this.
After 2 days of researching, I found that if I removed the foreign characters (in this case, Punjabi) in the XML file, it loaded fine! Now realizing it was a foreign character / unicode issue, I googled some more.
I changed the following:
and it works!
BUT, the problems continued. Now my <br /> tags were appearing as <br /> and so now <br /> was being printed on the screen. I changed the line to:
Replace(Server.HtmlEncode(strContent), "<br />", "<br />")
but then IT BROKE AGAIN (Same as before: page would load, but then immediately go blank)! An hour later, I added VbCrLf before and after the <br /> tags, so the break tags would be on a different line than any foreign character. I updated the line to this:
Replace(Server.HtmlEncode(strContent), "<br />", vbCrLf & "<br />" & vbCrLf)
Now the <br /> tags were being rendered correctly, foreign characters were displaying correctly and IE was behaving as I expected it to!
I hope this helps someone solve their problem, or at least provide a starting point if they are experiencing this strange problem.