A HTML Host control was always an useful add on for lot of Silverlight apps. The previous HTML Host that I published on Html host blog link did have some short-comings.
- It did not have support for browsers like Mozilla, Firefox, Opera. Though it displayed the content on these browsers invoking a javascript function etc., were not working well. But it was doing its job in Internet explorer 7 & above
- There was no inbuilt functions added for invoking javascript functions
- There was no support for placement of the control with reference to Screen resolution, which is very important
So just thought a properly built version may be useful for everyone. Also with this control, there is no need to call the InitControl() function.
- Just drop the control on the page
- Set the TOP, Left, Height and Width in your program
- Set the HostVisible property to true and there you go
I have included a sample program along with this article. Feel free to use it and let me know in case you face any issues. If you need to invoke any javascript function inside the page, please use the functions like InvokeScript and InvokeScriptWithReturnValue.
This version is tested with FireFox 3.6.x, Opera 10.53 and IE 7 & above. The only change was by using the following function to get a reference to the iframe window.
String strwindoweveal = String.Format("document.getElementById('{0}').contentWindow", iFrame.Id);
Note:: Just make sure you include System.Web.Silverlight.dll
in your asp .net project, which I did’t take care to include from the correct directory.
Please follow the link Silverlight HtmlHost Source and Sample Project download and try the sample your self.