0

我需要根据从 Jquery 对话框中的第一个下拉列表中选择的值更新我的第二个下拉列表从数据库中。

ASPX

<asp:UpdatePanel ID="upnl" OnLoad="upnl_Load" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="dv" style="display: none;" title="Tile">
<table>
    <tr>
        <td>Parent</td>
        <td>
            <asp:DropDownList ID="ddlDialog1" runat="server" /></td>
    </tr>
    <tr>
        <td>Child</td>
        <td>
            <asp:DropDownList ID="ddlDialog2" runat="server" /></td>
    </tr>
</table>
</div >
</ContentTemplate>
</asp:UpdatePanel>

jQuery

function ShowDialog() {
jQuery(document).ready(function () {
    $("#dv").dialog({
        draggable: true,
        modal: true,
        width: 500,
        height: 400
    });
});
}

jQuery(document).ready(function () {
$("#<%= ddlDialog1.ClientID %>").change(function () {
   //This doesn't fire
    __doPostBack('<%= upnl.ClientID %>', "DialogOnChange");
});
});

这里的问题是,当我从第一个下拉列表(ddlDialog1)中选择不同的值时,如何更改功能不会触发。

任何想法?

4

2 回答 2

1

由于$("#dv").dialog();使您的文档更改。

您必须$("#<%= ddlDialog1.ClientID %>")在对话框打开后绑定。

$("#dv").dialog({ 
  //...,
  open: function(){
    //..bind item in this dialog
  },
});
于 2013-09-09T03:55:19.083 回答
0

这可能会对您有所帮助。

$('#ddlDialog1').change(function(){            
        alert(Selected Value : + $('#ddlDialog1').val());    
});​
于 2013-09-09T13:40:08.970 回答