USING Windows Forms Controls in Internet Explorer
This document describes how to successfully execute Windows Forms controls within Internet Explorer (IE). Windows Forms controls within IE are activated without user prompt, require no registration and utilize the Common Language Runtime (CLR) code access security.
There Are Four Steps in getting The Windows Forms Control ActiVated Withnet Explorer, Each Listed Here and Det Below.
Configure code Access Permissions Create An Html Document with an Object Tag Create The Virtual Directory, Copy Content and Set Permissions Run THE CONTOL
1. Windows Forms Control: SimpleControl.dll
Almost Any Windows Forms Control Could BE, But for this Example The SimpleControl That INCLUDEDITART TUTORIAL CREANG CONTLS WILL BE.
2. HTML Document: SimpleControl.html
The next step is to create an HTML document with and object tag to insert and activate the Windows Forms control. Some simple script and input tags will also be added to demonstrate programmatic access to the control.
Object Tag
ClassID = "http: simplecontrol.dll # microsoft.samples.winforms.cs.simplecontrol.simplecontrol"
HEIGHT = "300"
Width = "300">
Object>
The classid has two interesting parts;.. The path to the control library and the fully qualified name of the control separated by the pound sign If you are familiar with an ActiveX object tag, youll notice the lack of a GUID In the case of Windows Forms, the combination of path and fully qualified classname serve as the unique identifier.Param tags are used to set properties on controls. The name attribute is the name of the property and the value attribute is the value of the property.
Script
Function ChangeText () {
SimpleControl1.Text = Text1.Value;
}
script>
To gain programmatic access to your control, you can write script against it. A button and text box on the page is used in conjunction with the simple function ChangeText to set the text property of the control.
Complete
The Following Is The Complete Html Code for this Example.
Function ChangeText () {
SimpleControl1.Text = Text1.Value;
}
script>
Simple Control P>
ClassID = "http: simplecontrol.dll # microsoft.samples.winforms.cs.simplecontrol.simplecontrol"
HEIGHT = "300"
Width = "300">
Object>
body>
html> 3. Virtual Directory
Create a New Virtual Directory and Populate It with Both The Control (SimpleControl.dll) and The HTML Document (SimpleControl.html).
Important: SET Execution Permissions on the Virtual Directory To Scripts. The Control Will Not Be Properly ActiVated If The Execution Permissions Are Set To Scripts & Executables.
4. Configure Code Access PermissionsThis sample will execute correctly if you are running the control from an intranet site and you have not altered the .Net Framework security policy. If you have altered policy, or if you are running the control from an internet site then you may need to configure Internet Explorer or alter security policy to allow it to run. One way to enable a specific site for control download and execution is to identify your hosting page as belonging to the Trusted zone. This change is done in Internet Explorer with The Following Steps.
Choose Tools | Options
2. SELECT The "Security" Tab
3. Select the "trusted sites" icon
4. Click The Sites ... Button
5. Add Your Site Using The Dialog Presented
6. Click ok to commit your change
Now, When You Browse to That Page, It Should Be in The Trusted Sites Zone Which Has The Internet Permission Set by Default.
You can also configure the .NET Framework security policy to enable Code to run from a particular web site or from the Internet. The SDK Documentation Contains Details of How To Configure Security Policy.
5. Run The Control
To run the control, just point Internet Explorer to SimpleControl.html in your virtual directory. If the control is not activating correctly it may be necessary to restart Internet Explorer or clear the assembly download cache.