How to host winform control in IE
阿新 • • 發佈:2020-10-09
Hosting a Windows Form Control in a web page
Although it is not the most common use of it, it is possible to host a Windows Form Control in a Web Page and run it from within Internet Explorer. This allows to build powerful client side functionality with all the advantages of using the .Net framework and executing the control in the client side. Of course there are some restrictions that cannot be left aside. At least the .Net framework must be installed on the client for the control to run. In addition, it is possible that some permission must be granted to the control, too, depending on the actions the control will take on the client machine.height="100" width="300" VIEWASTEXT/>
<br/><br/> <input type="button" onclick="SendMessageToWinControl()" value="Send Message" /> </body> </html> 3. Deploy the sample Copy both the index.html page and the control library WindowControlLibrary1.dll to a directory (we will name it WinControlTest). In the “Web Sharing” dir properties select Share this folder, leave the default alias and application permissions to Scripts and make sure not to select the Execute permission). 4. Try it in Internet Explorer Open the page [url]http://localhost/WinControlTest/index.html[/url]in Internet Explorer. We can see the control hosted in the html page: By clicking the Send Message button,we will call the Control's SendMessage method from javscript. Resulting in thelabel's text changed: If you modify the control after its first use, you will need to close IE, replace the control's dll in the virtual directory and clean the contents of the download cache. You do this cleaning using the following command: "gacutil /cdl".Tolist the contents of the download cache use "gacutil /ldl". This solution is not intended to replace a WebControl or any common web artifact. But is good to know it can be use inan uncommon scenario if needed. Other references: [url]http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsIeSourcing.aspx[/url] [url]http://www.eggheadcafe.com/articles/20021205.asp[/url] [url]http://dotnet.org.za/codingsanity/archive/2006/04/20/51710.aspx[/url]