C # WinForms: should I use a web browser control

I am creating a Windows Forms application in which I will add a control in which quite a lot of different data will be displayed. For the most part, the data inside will be navigation buttons and help / training text.

I think it would be ideal if I could write the content in HTML and then just display it in the control in the application, but I'm not sure if this is a good idea.

One more note: at some point in the near future there will be a web version of the same application, and this part of the application in HTML will make very easy reuse.

Users will not have IIS installed, if that matters.

+4
source share
2 answers

I have a similar application and I think that managing WebBrowser works very well. If you think what you need, I would for this and there are many other applications that do something like this. You can call Javascript functions on an HTML page with C # using HtmlDocument.InvokeScript() and C # from Javascript using window.external , and this two-way communication makes life simple.

Users do not need to install IIS because you are not using a web server, just displaying the content using HTML.

I would go for IE built-in control, not webkitdotnet, to be honest. Although WebKit itself is superior to IE, the webkitdotnet project in version 0.5 does not have C # and JavaScript or DOM access, and it seems difficult to tell if it is actively developing. It will be great if / when it gets the parity of characteristics, since IE is clearly far from perfect, but the advantage of the built-in IE control is that each user of your application will already be installed, and the WebBrowser control will be well tested. There are some flaws I found:

  • The version of IE can vary from 6 to 9, so you should test to make sure your content works in everything (like with a website).
  • There is an error in IE (at least up to 8) that relative links do not work in conjunction with <base href="file://..."> . This may prevent you from using relative links in your local HTML documents.
  • Sometimes pages are displayed differently inside the WebBrowser control than from it. For example, http://bugs.jquery.com/ticket/7104 is one, and I came across another similar error affecting cufon.
  • For compatibility reasons, even if your users install IE> 7, the WebBrowser control will still display your content in the default IE7 rendering mode. This is different from stand-alone IE, which by default works in standard mode, so it can catch you if you do not expect it. You can change this by adding the <meta http-equiv="X-UA-Compatible" tag if you want, although I actually found this to make life easier, as it reduces the number of different versions that you should test.
+2
source

To this end, I believe that the built-in web browser will be absolutely great. Several applications use a web browser control for navigation, information, training, etc. Steam is one example. In addition, reuse is almost always the best practice.

But I would use WebKit instead of the built-in IE web browser control.

+6
source

All Articles