selectedindexchanged not firing with onchange method in javascript

Posted by Amitavin under ASP.NET on 4/8/2013 | Points: 10 | Views : 5742 | Status : [Member] | Replies : 1
please help me i'm facing a problem with dropdown list i'm using javascript method "onchange" to get dropdown selected value i get the value but dropdown selectedIndexChanged event not firing please someone help me

my javascript function is that for getting selected value:
<script type="text/javascript" language="javascript">
function showAddress_Byamit()
{
var e = document.getElementById("TabC_tp1_ddlcountry");
var country = e.options[e.selectedIndex].text;
}
</Script>
javascript function work well it return selected value but problem with C# code behind

<asp:DropDownList
ID="ddlcountry" runat="server" AutoPostBack="True" Height="20px" EnableViewState="true"
OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged" TabIndex="4" onchange="showAddress_Byamit(); return false"
Width="100px" ></asp:DropDownList>

here problem is that event "ddlcountry_SelectedIndexChanged" not firing

and in codebehind i add Onchange event as:
ddlcountry.Attributes.Add("onchange", "showAddress_Byamit(); return false");




Responses

Posted by: Jitendrasoft09 on: 4/10/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi,
You are firing the java script function not dropdown selected event as not happening post back, please refer below link-
http://stackoverflow.com/questions/1007190/want-to-fire-dropdown-selectedindexchanged-event-in-javascript

Jitendra Kumar
If my post helps you, plz mark as an answer.

Amitavin, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response