Wednesday, May 16, 2007

Playing around with Embedded Objects in IE

Yesterday I felt like playing around a bit with embedded objects in IE - you know, showing Windows Forms in a browser. An old .NET trick that I've used a couple of times.

For some reason it has never quite become the market standard it was supposed to (probably because it's ugly, inefficient and very browser specific) - but it would have been nice with a good alternative to java applets!

I made a quick adaptation of the SudokuSolver from my previus post to see how it would work as an embedded object. This is what I did:
  1. Made a Windows Forms Library project
  2. Made a Windows Forms User Control
  3. Moved the UI from the Sudoku application to the new User Control (as well as the Code Behind)
  4. Compiled and put on a web-server
  5. Made a HTML Page that includes it as an embedded object, and put the page on the same webserver (this is important)
This is the HTML I used, notice how you provide it with the URL to the Windows Forms DLL, and then the full path (including namespace) to the control to display:


<object id="SudokuControl" height="240" width="206"
classid="http://www.thraen.dk/Download/SudokuWinLib.dll#SudokuWinLib.Sudoku">
</object>


If you are watching this blog in IE, and you have .NET 2.0 installed, and your security settings is just right, there is a chance that you might actually see the Sudoku Solver here:


No comments: