Tornado
Keywords: Asp, ActiveX control, digital signature, security
Question:
The ActiveX Control obtains the client information. How do I transmit the information to the server ???
One method is to get the value and use the get and post methods for submission, which may be the most common.
Is there any better way?
Can I directly send a request to the server in the control to obtain the data?
Open VB6 and create an ActiveX control project.
Project name: focx, user control name: uc3
Add one button and two text boxes
The Code is as follows:
Option explicit
Private sub commandementclick ()
'Note that the writing of strings and numbers is different.
'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 data from ASP pages.
'The event occurs when the container has just completed an asynchronous read request?
The value in 'asyncprop specifies a completed asynchronous data read request,
'It matches the data in the previous asyncread method call.
The 'asyncreadcomplete event should contain the error handling code, because the download will be terminated due to the error status.
'If this happens, an error will occur when accessing the Value Attribute of the asyncproperty object.
Private sub usercontrol_asyncreadcomplete (asyncprop as asyncproperty)
On Error goto errhandle
Text2.text = bytearraytostring (asyncprop. value)
Errhandle:
Err. Raise 601, "An error occurred during asynchronous reading", Err. Description
End sub
'Convert byte arrays into strings
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 the http: // Yang/XML/ActiveX. asp file.
<%
Dim Str
STR = request ("S1 ")
If STR = "name" then
Response. Write ("tornado ")
Elseif STR = "Age" then
Response. Write ("26 ")
Else
Response. Write ("no available information is returned ")
End if
%>
It is easy to use the request to accept the parameter, and the response is returned.
In this example, the server name is passed to the control as an attribute.
For example: <Param name = "servername" value = "192.168.0.1">
Then you can get it in the program, such:
Usercontrol. asyncread "http: // 192.168.0.1/XML/ActiveX. asp? S1 = "& text1.text &" ", vbasynctypebytearray
Then, the program can be flexibly processed.