active|activex| Interaction | control
Keywords: Asp,activex controls, digital signatures, security
The ActiveX control runs on the client. We can get some information about the client, such as IC card information, client authentication and so on. However, the ActiveX control also has many disadvantages: The client's deployment is difficult, such as the client can not download correctly, the download can not be correctly executed, download the time required to set IE security level and so on.
More often, I use COM components to extend the functionality of the ASP. Specifically, the ActiveX DLL component that is running on the server side. You can complete a call to a component using Server.CreateObject ("project name. Class Name"). There are few problems with this approach, as long as the components are exposed to public external methods. However, sometimes we have to use ActiveX controls (*. OCX) is embedded in the Web page to get information from the client. This has a lot of problems.
This is the n problem we need to solve (from simple to difficult)
1. How to get data from the server side and pass it to the ActiveX control.
1) using parameter binding when initializing
2 run time to get data
2. The ActiveX control gets information about the client and how it is delivered to the server.
3. Security
1) Digital Signature
2) using the Iobjsafe interface
All right, let's start with the example study.
This feature demonstrates how to make a simple control and embed it in a Web page for execution.
Working environment: WINXP+VB6+IE6
My IE security is set to security level-medium. All ActiveX options are set to Enabled.
Open VB6 To create a new ActiveX control project.
Project name: focx, User control name: UC1
For convenience, we use the ActiveX Control Interface Wizard ..., menu-> add-in-> add-in Manager->vb 6 ActiveX Control Interface Wizard. sure you can.
Open the ActiveX Control Interface Wizard, and next, for the available names and selected names, we default next, create a new custom member, GetInfo type: Properties, next, a common method to select the GetInfo we just added, map to the control selection Txtinfo, the member select text, The next step is done. The code window will generate something we don't need, delete, and the rest of the code is as follows:
Option Explicit
Attention Do not delete or modify the following commented lines!
' Mappinginfo=txtinfo,txtinfo,-1,text
Public Property Get GetInfo () as String
GetInfo = Txtinfo. Text
End Property
Public Property Let GetInfo (ByVal New_getinfo as String)
Txtinfo. Text () = New_getinfo
PropertyChanged "GetInfo"
End Property
' Load the property value from the memory
Private Sub usercontrol_readproperties (propbag as PropertyBag)
Txtinfo. Text = Propbag.readproperty ("GetInfo", "Text1")
End Sub
' Write attribute values to storage
Private Sub usercontrol_writeproperties (propbag as PropertyBag)
At the same time, open your IE browser and see that the controls you make appear on this test page.
You can open the test page and see the CLSID, for example: 890D1028-298B-45CF-9A64-6ED5A5BACBC9
Since the VB compile time has completed registration. It is not possible to simulate a prompt that occurs when the client does not have the control installed.
We continue to
Uninstall using regsvr32 f:\csdn_vb\com+_activex\sample1\focx.ocx–u
Or
Open the registry and find it under HKEY_CLASSES_ROOT\CLSID
890D1028-298B-45CF-9A64-6ED5A5BACBC9 items, delete, of course, this way there are still items exist but not deleted clean.
At this point, browse http://yang/uc1.htm, because ActiveX in IE is set to boot, the control is displayed.
After the download OCX to where to???
Open the directory (may vary) E:\WINDOWS.0\Downloaded program files, see, focx.uc1 files are in this directory.
Principle: After the client downloads the control, it is automatically registered and placed in the directory above. Then we can open the registry to see the CLSID, hehe, or the old one.
We can right-click on the FOCX.UC1 properties and look at the relevant content, which shows all the files that OCX relies on. So, your OCX minimize the use of advanced controls or Third-party controls, otherwise, the download has some problems.
If the option for ActiveX in IE is set to disabled, the browser will appear with the dialog box "Current security setting prevents ActiveX controls from running on the page." Therefore, the page may not be displayed correctly, and this requires other ways to handle it.
The general user defaults to disabling the ActiveX option, so it is not appropriate for the user to set their own settings.
Let's take a look at how to get the data from the server and pass it to the ActiveX control.
1) using parameter binding when initializing
2 run time to get data
Open VB6 To create a new ActiveX control project.
Project name: focx, User control name: UC2
For convenience, we use the ActiveX Control Interface Wizard ..., menu-> add-in-> add-in Manager->vb 6 ActiveX Control Interface Wizard. sure you can.
Open the ActiveX Control Interface Wizard, and next, for the available names and selected names, we default next, create a new custom member, GetInfo type: Properties, next, a common method to select the GetInfo we just added, map to the control selection Txtinfo, the member select text, The next step is done. The code window will generate some we don't need, delete,
Attention Do not delete or modify the following commented lines!
' Mappinginfo=txtinfo,txtinfo,-1,text
Public Property Get GetInfo () as String
GetInfo = Txtinfo. Text
End Property
Public Property Let GetInfo (ByVal New_getinfo as String)
Txtinfo. Text () = New_getinfo
PropertyChanged "GetInfo"
End Property
Private Sub Command1_Click ()
Label2.Caption = GetInfo ()
End Sub
' Load the property value from the memory
Private Sub usercontrol_readproperties (propbag as PropertyBag)
Txtinfo. Text = Propbag.readproperty ("GetInfo", "Text1")
End Sub
' Write attribute values to storage
Private Sub usercontrol_writeproperties (propbag as PropertyBag)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.