PRB: Forms 2.0 CommandButton Fires Click Event When Disabled (188766)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01

This article was previously published under Q188766

SYMPTOMS

The Forms 2.0 CommandButton control can be disabled by setting the value of its Enabled property to false.

When this control is placed inside a table cell on a Web page, the Click event for the control can be fired even though the control is disabled.

The Click event for the control cannot be fired if the control is disabled and placed outside of a table.

CAUSE

The Forms 2.0 controls were designed and tested for use with Visual Basic and Visual basic for Applications, not for Microsoft Internet Explorer.

RESOLUTION

  1. The recommended resolution for this problem is to use the intrinsic button control by specifying the following HTML:
    <INPUT TYPE=BUTTON ID=MyButton VALUE="My Button">
    						
    The following script disables the control when the page is displayed:
    <SCRIPT LANGUAGE=VBScript FOR=Window EVENT=onload>
    <!--
       MyButton.disabled = True
    -->
    </SCRIPT>
    						
  2. If you decide to continue using the Forms 2.0 CommandButton control, you can check the Enabled property of the control when handling the Click event, as demonstrated below:
    <SCRIPT LANGUAGE=VBScript FOR=MyButton EVENT=Click>
    <!--
       if ( MyButton.Enabled ) then
          MsgBox "MyButton_Click fired"
       else
          MsgBox "MyButton disabled"
       end if
    -->
    </SCRIPT>
    						

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

The following HTML demonstrates this problem:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBScript FOR=Window EVENT=onload>
<!--
  MyButton.Enabled = False
-->
</SCRIPT>
<SCRIPT LANGUAGE=VBScript FOR=MyButton EVENT=Click>
<!--
  MsgBox "MyButton Click fired"
-->
</SCRIPT>
</HEAD>

<BODY>
<TABLE BORDER=1>
 <TR>
  <TD>
    <OBJECT ID=MyButton
     CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57">
      <PARAM NAME="Caption" VALUE="My Button">
      <PARAM NAME="Size" VALUE="2540;847">
      <PARAM NAME="ParagraphAlign" VALUE="3">
      <PARAM NAME="FontWeight" VALUE="0">
    </OBJECT>
   </TD>
  </TR>
</TABLE>
</BODY>
</HTML>
				

REFERENCES


Modification Type:MajorLast Reviewed:10/29/1999
Keywords:kbcode kbDHTML kbHTMLObj kbieObj kbprb KB188766