Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / January 2006

Tip: Looking for answers? Try searching our database.

WebBrowser in .NET 2.0: !DOCTYPE gets overwridden

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joubert Nel - 23 Dec 2005 22:27 GMT
Hi,

I have an XHTML document that I wish to display to the user in the .NET 2.0 WebBrowser control, and allow the user to edit it.

I got everything working beautifully but noticed that the control tampers with the !DOCTYPE definition.
Here is the XHTML that I pass to the WebBrowser control:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>HtmlEditor</title>
<style type="text/css">
BODY {font-family:Tahoma; font-size:10pt; color:#000000; font-weight:400; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px}
</style>
</head>
<body>
</body>
</html>

As you can see, this is simply a template, giving the user a blank slate where they can now edit.

However, after the above snippet is loaded by the WebBrowser (I use the .Document.OpenNew(); and then .Document.Write(".....") methods) the !DOCTYPE is changed to:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Does anybody know why this is happening, what the potential effects are, and how I can resolve?

Thanks

Joubert
Herfried K. Wagner [MVP] - 24 Dec 2005 11:05 GMT
"Joubert Nel" <j@j.com> schrieb:
>I have an XHTML document that I wish to display to the user
> in the .NET 2.0 WebBrowser control, and allow the user to edit it.
>
>I got everything working beautifully but noticed that the control
> tampers with the !DOCTYPE definition.

I believe the problem is that IE doesn't support XHTML and treats it as
HTML.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

e_zverev - 17 Jan 2006 18:11 GMT
> I believe the problem is that IE doesn't support XHTML and treats it as
> HTML.
Don't believe this :) IE supports XHTML 1.1

The problem is that IE does not support a single character before the
DOCTYPE declaration. In your case this is "<?xml version="1.0"
encoding="utf-8"?>
" instruction that spoils the whole thing.

Remove everything before DOCTYPE, even a comment would be enough for IE to
get ignorant to your DOCTYPE.

THE question to MS guys is: why'o'why is this so...fragile?!

Oh man, I've spent an hour to find it out. It ran me nuts.

Signature

Eugene U. Zverev,
Senior Programmer

Herfried K. Wagner [MVP] - 17 Jan 2006 18:27 GMT
"e_zverev" <ezverev@discussions.microsoft.com> schrieb:
>> I believe the problem is that IE doesn't support XHTML and treats it as
>> HTML.
> Don't believe this :) IE supports XHTML 1.1

Not really.  It supports XHTML 1.0/1.1 if it is provided as 'text/html' and
treats it as normal HTML.  However, XHTML 1.1 is not indended to be made
available as 'text/html'.  'application/xhtml+xml' should be used as content
type for XHTML 1.1 documents instead.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Joubert Nel - 17 Jan 2006 20:28 GMT
Hello Eugene,

Some feedback inline.

Thanks
Joubert

>> I believe the problem is that IE doesn't support XHTML and treats it as
>> HTML.
> Don't believe this :) IE supports XHTML 1.1

From what I can gather on both MS and other sites (for example
http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx) this is not the
case.

For example, try to actually load XHTML into IE and then do a View Source.
Note the changes it makes

> The problem is that IE does not support a single character before the
> DOCTYPE declaration. In your case this is "<?xml version="1.0"
[quoted text clipped - 7 lines]
>
> Oh man, I've spent an hour to find it out. It ran me nuts.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.