PRB: Forms 2.0 CommandButton Fires Click Event When DisabledID: Q188766
|
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.
The Forms 2.0 controls were designed for use with earlier versions of Microsoft Internet Explorer.
<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>
<SCRIPT LANGUAGE=VBScript FOR=MyButton EVENT=Click>
<!--
if ( MyButton.Enabled ) then
MsgBox "MyButton_Click fired"
else
MsgBox "MyButton disabled"
end if
-->
</SCRIPT>
This behavior is by design.
<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>
© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Mark Davis, Microsoft Corporation
Additional query words:
Keywords : kbcode kbDHTML kbIE400 kbIE401 kbIEObj kbHTMLObj
Version :
Platform :
Issue type : kbprb
Last Reviewed: May 3, 1999