Microsoft KB Archive/200105

= PRB: OptionGroup DTC Does Not Respond to OnChange Event =

Article ID: 200105

Article Last Modified on 4/22/2001

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q200105



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:  Create a new Active Server Pages (ASP) page. Drag-Drop an OptionGroup DTC, edit its property window and have it display Option1, Option2, Option3 with values as 1, 2, 3 accordingly. Change the Scripting Platform of the OptionGroup DTC to Server (ASP).  Add the following function to the page:

 function thisPage_onenter{ OptionGroup1.advise("onclick",OptionGroup1_onclick); }    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> </li> View the ASP page in the browser. Now, when you click on any of the options, the event handler is automatically invoked.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="references_section">