Interaction between ASP and ActiveX Controls (III)

Source: Internet
Author: User

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.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.