Jquery模式没有从asp下拉列表中获得选定值

本文关键字:下拉列表 模式 asp Jquery | 更新日期: 2023-09-27 18:05:02

我使用jquery的简单模态。

function showCancelledModal() {
    $('#<%=CancelledPanel.ClientID %>').modal({ appendTo: 'form' });
}
<asp:Panel ID="CancelledPanel" runat="server" Style="display: none">
  <asp:DropDownList ID="CancelledDropDownList" runat="server"></asp:DropDownList>
  <asp:Button ID="CancelButton" runat="server" Text="Cancel" OnClick="CancelButton_Click" />
</asp:Panel>
protected void CancelButton_Click(object sender, EventArgs e)
{
   var item = CancelledDropDownList.SelectedItem.Value;
   //CancelReservation(strReservationId); 
}

问题是,在我的按钮单击事件,它似乎没有得到下拉列表的选定值。它每次都默认为第一个值。我将下拉列表绑定到页面加载事件中的一个表。

谁能给点建议?

Jquery模式没有从asp下拉列表中获得选定值

我不能发表任何评论(可能是因为我是新来的,没有名气!)所以,它开始了……这是非常基本的,但是您确定没有在每次回发时绑定下拉列表吗?

ie。像这样忘记:

private void Page_Load()
{
    if (!IsPostBack)
        CancelledDropDownList.DataBind(); // this method will reset the SelectedValue
}

欢呼