[英]SelectedIndexChanged event not firing with OnChange method in JavaScript
Please help me with a problem I'm having with a DropDownList
. 请帮我解决
DropDownList
遇到的问题。 I'm using the JavaScript "onchange" method to get the DropDownList's selected value. 我正在使用JavaScript“onchange”方法来获取DropDownList的选定值。 I can get the value, but the
OnSelectedIndexChanged
event not firing. 我可以得到值,但
OnSelectedIndexChanged
事件没有触发。 Hopefully someone can help me. 希望有人可以帮助我。 My JavaScript function for getting selected value is:
我获取选定值的JavaScript函数是:
<script type="text/javascript" language="javascript">
function showAddress_Byamit()
{
var e = document.getElementById("TabC_tp1_ddlcountry");
var country = e.options[e.selectedIndex].text;
}
</Script>
<asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="True"
Height="20px" EnableViewState="true" TabIndex="4"
OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged"
onchange="showAddress_Byamit();return false" Width="100px" >
</asp:DropDownList>
The problem is that the "ddlcountry_SelectedIndexChanged"
method is not called. 问题是没有调用
"ddlcountry_SelectedIndexChanged"
方法。
In the codebehind I have added the Onchange
event as follows: 在代码隐藏中,我添加了
Onchange
事件,如下所示:
ddlcountry.Attributes.Add("onchange", "showAddress_Byamit(); return false");
你需要删除return false
ddlcountry.Attributes.Add("onchange", "showAddress_Byamit();");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.