Active|activex| Interaction | Control tornado
Keywords: Asp,activex controls, digital signatures, security
Questions raised:
ActiveX controls get information about the client and how to deliver to the server???
One way to do this is to get the value and submit it using the Get,post method, which is probably the most common.
Is there a better way?
Can you make a request to the server directly from the control and get the data?
Open VB6 To create a new ActiveX control project.
Project name: focx, User control name: UC3
Add 1 buttons, 2 text boxes
The code is as follows:
Option Explicit
Private Sub Command1_Click ()
' Note that there are some differences in the wording of strings and numbers
' Use AsyncRead to send your request over HTTP
Usercontrol.asyncread "http://yang/xml/activex.asp?s1=" & Text1.Text & "", Vbasynctypebytearray
Usercontrol.asyncread "http://yang/xml/activex.asp?s1=" & Text1.Text, Vbasynctypebytearray
End Sub
The ' AsyncReadComplete event is used to receive and analyze from an ASP page.
' When the container has just completed an asynchronous read request, the event occurs?
The value in ' Asyncprop specifies an asynchronous data read request that has been completed.
' It matches the data in the previous AsyncRead method call.
' The AsyncReadComplete event procedure should contain error handling code because the error state terminates the download.
' If this happens, an error occurs when accessing the Value property of the AsyncProperty object.
Private Sub Usercontrol_asyncreadcomplete (Asyncprop as AsyncProperty)
On Error GoTo Errhandle
Text2.text = ByteArrayToString (asyncprop.value)
Errhandle:
Err.Raise 601, "error occurred with asynchronous read", Err.Description
End Sub
' Converts a byte array into a string
Public Function bytearraytostring (Bytarray () as Byte) as String
Dim SAns as String
SAns = StrConv (Bytarray, Vbunicode)
ByteArrayToString = SAns
End Function
Let's take a look at http://yang/xml/activex.asp this file.
<%
Dim str
Str=request ("S1")
If str= "name" Then
Response.Write ("Tornado")
ElseIf str= "Age" then
Response.Write ("26")
Else
Response.Write ("No information available to return")
End If
%>
Very simply, use request to accept parameters, response returns.
This example can be further processed by passing the server name to the control in the form of a property.
For example: <param name= "ServerName" value= "192.168.0.1" >
Then you get it in the program, you can use it, such as:
Usercontrol.asyncread "http://192.168.0.1/xml/activex.asp?s1=" & Text1.Text & "", Vbasynctypebytearray
Then you get it in the program and you can handle it flexibly.