ASP and ActiveX control interactive Combat (iii)

Source: Internet
Author: User
Tags error handling
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.



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.