如何在asp.net c中使用javascript从ajax组合框中获取选定值#

如何在asp.net c中使用javascript从ajax组合框中获取选定值#,javascript,c#,jquery,asp.net,ajax,Javascript,C#,Jquery,Asp.net,Ajax,我想使用asp.net c中的javascript从ajax combobox selected项中获取所选值# 这是我的密码 <asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction()" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="

我想使用asp.net c中的javascript从ajax combobox selected项中获取所选值#

这是我的密码

<asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction()" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="15px" MaxLength="50">
</asp:ComboBox>

function blurFunction()
{
     var ddlReport = document.getElementById("<%=dropdown_dest.ClientID%>").value;
     alert(ddlReport);
}

函数
{
var ddlReport=document.getElementById(“”)值;
警报(报告);
}
在警报中,它显示未定义

请帮我解决这个错误


谢谢。

如果您可以使用jquery,您可以这样做:

<asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction()" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="15px" MaxLength="50">
</asp:ComboBox>

function blurFunction()
{
    var ddlReport = $("#" + "<%=dropdown_dest.ClientID%>").find("option:selected").val();
    alert(ddlReport);
}

函数
{
var ddlReport=$(“#“+”).find(“选项:选定”).val();
警报(报告);
}

如果您可以使用jquery,您可以这样做:

<asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction()" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="15px" MaxLength="50">
</asp:ComboBox>

function blurFunction()
{
    var ddlReport = $("#" + "<%=dropdown_dest.ClientID%>").find("option:selected").val();
    alert(ddlReport);
}

函数
{
var ddlReport=$(“#“+”).find(“选项:选定”).val();
警报(报告);
}
我还没有测试

<asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction(this)" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="15px" MaxLength="50">
</asp:ComboBox>

<script>

function blurFunction(e) {
var val = e.options[e.selectedIndex].value;
console.log(val);
}
</script>

函数模糊函数(e){
var val=e.options[e.selectedIndex].value;
控制台日志(val);
}
使用“this”将跳过jquery循环,js脚本可以放在单独的文件中

我还没有测试

<asp:ComboBox ID="dropdown_dest" runat="server" Width="90%" onfocusout="blurFunction(this)" AutoCompleteMode="SuggestAppend" CssClass="ComboboxWidth" DropDownStyle="DropDownList" Height="15px" MaxLength="50">
</asp:ComboBox>

<script>

function blurFunction(e) {
var val = e.options[e.selectedIndex].value;
console.log(val);
}
</script>

函数模糊函数(e){
var val=e.options[e.selectedIndex].value;
控制台日志(val);
}

使用“this”将跳过jquery循环,js脚本可以放在单独的文件中

打字错误:
(“%=dropdown\u dest.ClientID%>”
缺少
抱歉键入错误尝试使用
var ddlReport=document.getElementById(“dropdown\u dest”).value键入错误:
(“%=dropdown\u dest.ClientID%>”
缺少
抱歉键入错误尝试使用
var ddlReport=document.getElementById(“dropdown\u dest”).value
@karan即使使用
$(“#“+”)
也返回未定义?@karan即使使用
$(“#“+”)
也返回未定义?