PRB: OptionGroup DTC Does Not Respond To OnChange Event

ID: Q200105


The information in this article applies to:
  • Microsoft Visual InterDev, version 6.0


SYMPTOMS

When clicking on an OptionGroup Design-Time Control (DTC) whose Scripting Platform is set to "Server (ASP)," the OnChange event does not fire immediately. Specifically the OnChange event does not fire until the control has lost its focus.


CAUSE

The OnChange event of a Radio Button control does not fire until the Radio Button control has lost its focus. Since the OptionGroup DTC essentially uses HTML Radio Button controls to implement its OnChange event, the event handler for the OnChange event is not called until the user clicks outside the Radio Button control.


RESOLUTION

To allow code to respond immediately to user input for the OptionGroup DTC, you can use the OnClick event for the Radio Button control. Since the OnClick event is not an event available to the script object of the OptionGroup DTC, you can use the advise method to register this event.

Use the following steps to do so:

  1. Create a new Active Server Pages (ASP) page.


  2. Drag-Drop an OptionGroup DTC, edit its property window and have it display Option1, Option2, Option3 with values as 1, 2, 3 accordingly.


  3. Change the Scripting Platform of the OptionGroup DTC to Server (ASP).


  4. Add the following function to the page:
    
    <SCRIPT LANGUAGE=javascript RUNAT=server>
    function thisPage_onenter(){
       OptionGroup1.advise("onclick",OptionGroup1_onclick);
    }
    </SCRIPT> 


  5. Add the event handler for the OnClick Event:
    
    <SCRIPT LANGUAGE=javascript RUNAT=server>
    function OptionGroup1_onclick(){
       var temp;
       temp = OptionGroup1.getValue();
       if (temp==1){
          Response.Write ('Option1 selected');
       }else if (temp==2){
          Response.Write ('Option2 selected');
       }else{
          Response.Write ('Option3 selected');
       }
    }
    </SCRIPT> 


  6. View the ASP page in the browser. Now, when you click on any of the options, the event handler is automatically invoked.



STATUS

This behavior is by design.


REFERENCES

Q193229 BUG: Onchange Unavailable in VBScript with OptionGroup DTC

Additional query words:

Keywords : kbCtrl kbScript kbVisID600 kbGrpASP
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: March 21, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.