According to the needs of the online monitoring project, it is necessary to be realistic to run the smartclient program in IE, and to be able to interact with the client's JavaScript.
The. net sdk documentation contains the following descriptions:
- The Windows Form Control in IE can be activated without a user prompt. It does not require registration and complies with the access security rules of the Common Language Runtime Library (CLR) code;
- Almost any windows form control can be carried in IE. The control must be installed in the Global Assembly Cache (GAC) or be located in the same virtual directory as the web page using it;
- The execution permission of the IIS virtual directory must be a pure script; otherwise, the control to be used cannot be activated.
To run the Windows Forms control in IE, follow these steps:
- Create a Windows Form Control:
Create a Windows control library project, which is the same as a common control library.
- Create HTML document that references the Windows Form Control:
Add the object tag to the HTML document, which references Windows Forms controls such:
<Object ID = "smartclient1" classid = "http: clientlib/smartclientlib. dll # smartclientlib. usercontrol1"
Width = "300" Height = "300">
<Param name = "text" value = "simple control">
</Object>
The most important thing is the classid, which includes the relative path to the control library and the fully qualified name of the control. Unlike the ActiveX Object Tag, The GUID is not required for Windows form controls, in Windows Forms controls, paths and fully qualified class names are used as unique identifiers. You can also use Param tags to set properties on the control. name indicates the name of the property and value indicates the value of the property; you can also use JavaScript scripts to access public properties and methods of controls.
- Create a virtual directory and Set permissions:
As described above, set the permissions for the virtual directory where the web page is located and deploy the Windows Forms control.
- Run the control:
Start ie web browsing. Windows Forms can only run in IE browser, but cannot run in other browsers.
NOTE: If vs2005 is used for compilation, the form control cannot be normally displayed, or cannot interact with the client Javascript script. Copy all the windows form control code to a file and use it. net command line tool CSC/vbc for compilation, it can be displayed normally, I do not know what is going on.