Asp.net 下拉列表值在 jquery 对话框中不会更改

Asp.net drop down list value doesnt change within jquery dialog

本文关键字:对话框 jquery net 下拉列表 Asp      更新时间:2023-09-26

我有一个div,里面我有一个按钮和一个 asp.net 下拉列表。我看到下拉列表值没有改变。即。如果我从下拉列表中选择 30,所选值仍显示为默认值 15,当我选择 1 小时、2 小时、48 小时等时也会发生同样的事情。

.aspx

      <div id='one'>
     <asp:LinkButton ID="ConfigureAlerts" OnClick="btnConfigureAlerts_Click" runat="server">Configure Alerts</asp:LinkButton>
    </div>
    <div id="ViewModalPopupDiv2">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                <asp:Panel ID="Panel2" runat="server" HorizontalAlign="left" ScrollBars="Auto">
                <asp:Button ID="btnGetLogs" runat="server" Text="SendAlerts" OnClick="btnSendAlertEmail_Click"/>
<asp:Label ID="Label2" runat="server" Text="Set The Alert Email Interval to every :" CssClass="label"
                                    ForeColor="Black"></asp:Label>&nbsp&nbsp&nbsp
           <asp:DropDownList ID="ddlTimeInterval" runat="server" AutoPostBack="true" UseSubmitBehavior="false" >
                                    <asp:ListItem Text="15MIN" Value="15"></asp:ListItem>
                                    <asp:ListItem Text="30MIN" Value="30"></asp:ListItem>
                                    <asp:ListItem Text="1Hr" Value="60"></asp:ListItem>
                                    <asp:ListItem Text="2Hrs" Value="120"></asp:ListItem>
                                    <asp:ListItem Text="8Hrs" Value="480"></asp:ListItem>
                                    <asp:ListItem Text="24Hrs" Value="1440"></asp:ListItem>
                                    <asp:ListItem Text="48Hrs" Value="2880"></asp:ListItem>
                                </asp:DropDownList>
                                <br />                
</asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>

JavaScript

function ViewModelPopup2() {
        $("#ViewModalPopupDiv2").dialog({
                scrollable: true,
                width: 800,
                modal: true
            });
        }

aspx.cs

protected void btnSendAlertEmail_Click(object sender, EventArgs e)
        {
            // Code to send email
        }
protected void btnConfigureAlerts_Click(object sender, EventArgs e)
        {
        ScriptManager.RegisterStartupScript
                       (this, this.GetType(), "callScriptFunction", "ViewModelPopup2();", true);
        }
    }

关于我能做什么的任何建议?

您已经针对下拉列表设置了自动回发。设置该组意味着它正在回发并刷新导致选择默认值的控件。

<asp:button Id=" btnConfigureAlerts" runat="Server" OnClientClick="ViewModelPopup2()"></asp:button>
function ViewModelPopup2() {
        $("#ViewModalPopupDiv2").dialog({
                scrollable: true,
                width: 800,
                modal: true
            });
        };