ASP.NET - prevent firing textchanged event on every post back instead of other

Asked By muthuraman alexander on 05-Dec-11 06:48 AM
hi all

i have a text box with onTextChanged event in a web form
the text changed event is always getting fired instead of any other event in the page
for example
when i select the dropdown in the page the selected index changed event is not getting fired instead of that the text changed event is geting fired

i dnt know how to prevent/solve this situation....

please advice me
thanks in advance
MUTHU
balaji replied to muthuraman alexander on 05-Dec-11 07:11 AM
could you show me your code?
muthuraman alexander replied to balaji on 05-Dec-11 08:51 AM
hi thank u for ur reply
actually here my process is to load the city names in the drop down for the postal code entered in the text box
so i use the ajax update panel for the drop down and a javascript to do post back in which the textchanged event fired in the client side the drop down got populated.
this is working great for me..

but when i click any other elements like radio or button in the page the text changed event got fired once again the drop down list got populated again and so the selected value was not retained in the drop down ...

here is my sample code

aspx
------

<ajax:updatepanel id="update" runat="server">
<contentTemplate>

<table>
<tr>
<td>
<
asp:TextBox ID="BillToPostalCode" runat="server" EnableViewState="false" Width="90px"

onkeyup="javascript:RefreshBillingAddress();" MaxLength="10" ValidationGroup="OPC"

onchange="markRed(this)" OnTextChanged="BillToPostalCode_textChanged" AutoPostBack="false"></asp:TextBox>

</td>
</tr>
<tr>
<td>

<asp:UpdatePanel ID="Update1" runat="server" >

<ContentTemplate>

<asp:DropDownList ID="drp_billToSubhurb_New" runat="server" Width="200px"

OnSelectedIndexChanged="drp_billToSubhurb_New_selectedIndexChanged" EnableViewState="true" >

</asp:DropDownList>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="BillToPostalCode" />

</Triggers>

</asp:UpdatePanel>
</td>
</tr>
<tr>
.
.
.

other form elements like radio buttons , text fields , buttons
.
.
.
.
.
</tr>
</table>
</contentTemplate>
</ajax:updatepanel>


in cs page
-----------

</td></tr><tr>........</tr></table></contentTemplate></ajax:updatepanel>in cs page-----------

protected void BillToPostalCode_textChanged(object sender, EventArgs e)

{

// bind the drop down based on the text box value

}



thanks in advance
muthu