Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Panel - Textbox TextChanged Event is interfering with the DropDown SelectedIndexChanged event
    text
    copied!<p>Basics:</p> <ul> <li>I have a text box (txtDepositAmount) that people can enter a deposit amount into and a drop down (ddlSelectedTerm) that sets the terms.</li> <li>Through these two values I calculate the APY (lblCurrentApy). </li> </ul> <p>Rules: </p> <ul> <li>If only one of the values is selected I still want to do an update on the current APY label and clear it. </li> <li>If either value changes I want to update the current APY and recalculate. </li> </ul> <p>The problem:</p> <p>As soon as I click away from the textbox and onto the drop down to select my term the drop down flashes and closes because the textbox TextChanged event was just fired. </p> <p><strong>I have to click on the drop down a second time to be able to select anything!</strong> </p> <p>Do I need to change what event I'm looking at or do I need to move some of the controls outside of the UpdatePanel? Can this only happen if some of the business rules change? Should I just give up and go to javascript?</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;table width="100%"&gt; &lt;tr&gt; &lt;td align="left" style="width: 10%" class="LineAlign"&gt; &amp;nbsp; &lt;/td&gt; &lt;td align="left" style="width: 40%" class="LineAlign"&gt; &lt;asp:Label ID="lblDollarSymbol" runat="server" Text="$"/&gt; &amp;nbsp; &lt;asp:TextBox ID="txtDepositAmount" runat="server" AutoPostBack="true" TabIndex="1" MaxLength="14" ontextchanged="txtDepositAmount_TextChanged"/&gt; &lt;/td&gt; &lt;td align="left" style="width: 30%" class="LineAlign"&gt; &lt;asp:DropDownList ID="ddlSelectedTerm" runat="server" AutoPostBack="true" TabIndex="2" onselectedindexchanged="ddlSelectedTerm_SelectedIndexChanged"&gt; &lt;/asp:DropDownList&gt; &lt;/td&gt; &lt;td align="center" style="width: 20%"&gt; &lt;asp:Label ID="lblCurrentApy" runat="server"/&gt; &amp;nbsp; &lt;asp:Label ID="lblPercentSymbol" runat="server" Text="%"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="ddlSelectedTerm" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="txtDepositAmount" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload