How to receive/send data between Active-X and ASP?

I want create an Active-X by Delphi 5.

The Active-X can receive data from a ASP and send some other data return to the ASP.

Please show me an example which include
.ASP file and Delphi files.

If the answer is too big, i can give my
email.

Thanks for any help.

Ye Chen
ycAsked:
Who is Participating?
 
MattFlowerConnect With a Mentor Commented:
I think I know the answer that you are looking for.

If I am correct, you are looking to something like this in ASP:

<%
   Set Obj = Server.CreateObject("Project1.HelloWorld")
   Obj.Hello(ResultString)
   Response.Write ResultString
%>

In Delphi 5, the answer that you are looking for is under the ActiveX tab.  The object that you want is called an "Active Server Object".  This is a COM object that can be executed from an ASP page.

To create one, first create an ActiveX library.  (File->New->ActiveX tab->ActiveX Library)  Then create the Active Server Object.  (File->New->ActiveX tab->Active Server Object)

Once you have created once of these objects, add methods to the type library to allow your exchange.  In the example above, I would add a method called Hello.  It would have one parameter, probably a variant type.  (You can usually get WideString or OleVariant to work.)

After you compile the object, you have to register it.  You can register it either in MTS or COM.  To begin with, COM is nice because it will take out some of the complexity.  Just go out to a command prompt and type: RegSvr32 project1.exe

Now you should be ready to use it in your pages.  The ProgId of the object that you will use in your ASP page is generally something like your exename + "." + the name of your object, such as "Project1.SampleComponent".

Good Luck!

-Matt
0
 
ycAuthor Commented:
Hi, MattFlower

I am very glad for that the answer of you is so fast.

But the short code of you ASP sample is too simple. I want to know how the  describe of data (such as a integer) trans between.

Would you give me the code or example more detail?

Thank you very much.

Ye Chen

0
 
MattFlowerCommented:
I am happy that this is helping.

As far as variables go, keep in mind that in VBScript, there aren't variable types, everything is variant.  You can cast variables to particular types, but in general the variables are cast automatically.

Here is a more complicated data-entry example.  First, a data-entry page:

<html>
  <head>
    <title>Data Entry Page</title>
  </head>
  <body>
    <form action="process.asp">
      Name: <input type="text" name="UserName"><BR>
      Value1: <input type="text" value="FirstVal"><BR>
      Value2: <input type="text" value="SecondVal"><BR>
      <input type="submit" value="Say Hello">
    </form>
</html>

Now, the page that processes it:

<%
  UserName = Request.Form("UserName")
  Value1 = Request.Form("FirstVal")
  Value2 = Request.Form("SecondVal")
  Obj = Server.CreateObject("Project1.Hello")
  Obj.CreateHelloString(UserName, HelloString)
  Obj.AddNumbers(Value1, Value2, SumOfValues)
%>
<html>
  <head>
    <title>Process Name</title>
  </head>
  <body>
<h2>A big hello to <%=HelloString%></h2><BR>
The sum of the numbers you entered is <%=SumOfValues%>
  </body>
</html>

This example would involve an object with two methods.  In the AddNumbers method, all the parameters are variants.  The SumOfValues parameter is a var parameter, so the value can be returned.  

Does that help?

-Matt
0
 
ycAuthor Commented:
Hi, MattFlower

Thanks for your answer again.
Because i havd never done any ACTIVE X's programming, so i want to known how to receive UserName, Value1 and Value2 in my ACTIVEX?

I hope you give the example of ACTIVEX
project which coding by DELPHI5.

My email is yezhaoyuan@263.net.

See you later.

Ye Chen
0
All Courses

From novice to tech pro — start learning today.