HOWTO: Submitting Data from an ActiveX Control in a Form

Last reviewed: October 31, 1997
Article ID: Q172064
The information in this article applies to:
  • Microsoft ActiveX SDK, version 1.0

SUMMARY

In Internet Exlorer 4.0 (IE4) the default property of an ActiveX control in a form can be submitted with the form.

If the control does not have a default property or the HTML page is viewed in Internet Explorer 3.x (IE3), the contents of the ActiveX control in a form will not be included when the form is submitted. This article discusses how to submit the contents by using a hidden input field on the form.

MORE INFORMATION

In IE4 the contents of an ActiveX control in a form can be submitted with the form. The NAME is the identifier of the object tag (that is, <OBJECT NAME=MyControl CLASSID=...>), and the VALUE is the value of the default property of the control (if it exists). However, if any of the following cases are true, the contents of the control will not be included in the submit string:

   The object did not instantiate
   The object does not have an identifier
   The object does not have a default property
   The default property cannot be coerced into a string

For other controls, or for controls viewed in IE3, you can submit the value from an ActiveX control in a form to the server by using an <INPUT> tag whose type is "hidden." In response to the user selecting the "submit" button of the form, you can execute JavaScript code that will assign the value of the control to the hidden input field before it is sent to the server.

The following is a complete HTML example that demonstrates using the default property method with the Microsoft Forms 2.0 Textbox Control and the "hidden" input method with the Microsoft Calendar Control.

   <HTML>
   <BODY>
   <FORM NAME="MyForm" ACTION="http://server/scripts/GetInfo.asp"
       METHOD="post" onSubmit="MyFunc()">

   <OBJECT ID="TextBox1" NAME="TextBox1" WIDTH=300 HEIGHT=60
      CLASSID="CLSID: 8BD21D10-EC42-11CE-9E0D-00AA006002F3">
      <PARAM NAME="TextAlign" VALUE="2">
      <PARAM NAME="Text" VALUE="TextBox">

   </OBJECT>
   <BR>

   <OBJECT ID="Calendar1" WIDTH=288 HEIGHT=192
      CLASSID="CLSID:8E27C92B-1264-101C-8A2F-040224009C02"
DATA="DATA:application/x- oleobject;BASE64,K8knjmQSHBCKLwQCJACcAgAACADEHQAA2BMAAM0HBQAMAA8AAIAAAAAAAA Cg ABAAAIAAAKAAAQABAAIAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAC8AkRCAQAFQXJp YWwBAAAAkAFEQgEABUFyaWFsAQAAALwCwNQBAAVBcmlhbAyg
   ">
   </OBJECT>
   <BR>
   USERNAME: <INPUT TYPE="text" NAME="Username" SIZE="20"><BR>
   PASSWORD: <INPUT TYPE="password" NAME="Password" SIZE="20"><BR>
   <INPUT TYPE="hidden" NAME="RichText">
   <INPUT TYPE="hidden" NAME="Cal">
   <INPUT TYPE="submit" VALUE="Submit">
   <INPUT TYPE="reset">
   <p>
   </FORM>

   <SCRIPT LANGUAGE="JavaScript">
   <!--
      function MyFunc()
      {
         MyForm.RichText.Value = MyForm.RichTextBox1.TextRTF;
         MyForm.Cal.Value = MyForm.Calendar1.Value
      }
   -->
   </SCRIPT>

   </BODY>
   </HTML>

Using Active Server Pages on the server to receive this information would look like this:

   <%@ LANGUAGE="VBSCRIPT" %>
   <HTML>
   <BODY>
   The User Name is <%Response.Write Request.form("UserName")%><br>
   The Password is <%Response.Write Request.form("Password")%><br>
   The TextBox is <%Response.Write Request.form("RichText")%><br>
   The Calendar date is <%Response.Write Request.form("Cal")%><br>
   </BODY>
   </HTML>

In IE3, the value of TextBox1 would not be submitted with the form, and thus would not appear in the output from the ASP page.

Keywords          : vbsEnvtIE kbcode
Technology        : kbInetDev
Version           : 1.0
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 31, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.