WebBrowser component not displaying CSS 3

I am creating a piece of software that requires a WebBrowser component. Unfortunately, it will not display my page correctly.

My content uses this CSS style:

.content_mid{ background-image:url(http://img.awesome-o.net/Content_Mid.png); background-size: 100% 100%; vertical-align:text-top; padding-left: 40px; padding-right:20px; min-height:400px; } 

Since I already learned that the WebBrowser component uses the installed version of interwebs explorer, I checked the html in Internet Explorer and showed it perfectly.

Here you see what it shows in IE:

enter image description here

And this is how it is displayed in the webbrowser component:

enter image description here

So, I checked the browser version:

 Debug.WriteLine("WebBrowser version: " + webBrowser1.Version); output: WebBrowser version: 9.0.8112.16443 

That should be good, I think.

+6
c # css webbrowser-control
source share
3 answers

Just for further reference to other people in need of this:

First of all: Thanks to Boo and Lex Li To help me find the answer to my question.

You must set a specific registry to the desired value:

There are two different key sets for 32-bit and 64-bit applications.

32 bit:

 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION Value Key: yourapplication.exe 

64 bit:

 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION Value Key: yourapplication.exe 

The value for setting this key (taken from MSDN here) as decimal values:

 9999 (0x270F) Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive. 9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. 8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive. 8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. 7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. 

Even hard MSDn claims that 9000 is an automatically assigned value. Obviously, this is simply not true.

Below you can find the code to add these keys to your registry. Please do not forget that your application has a different process name when debugging.

 RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); if (key != null) { key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord); } key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); if (key != null) { key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord); } 

So thank you all and good luck

Edit: The user account must be disabled for this code to work.

+9
source share

This page describes how to force a browser control to use a specific rendering mode.

You can also try this doctype

 <!DOCTYPE html> 

And / Or this meta element in the head element

 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
+11
source share

you can also add a response header to the IIS Called X-UA-Compatible application with a value of IE = Edge. I usually add it to my web.config

0
source share

All Articles