我有一个div,其中有一个按钮和一个asp.net下拉列表。我看到下拉列表值没有变化。即。如果我从下拉列表中选择30,则所选值仍然显示为默认值15,当我选择1Hr,2Hrs,48Hrs等时会发生同样的事情。
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>   
<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);
}
}
关于我能做什么的任何建议?
答案 0 :(得分:1)
您在下拉列表中设置了AutoPostBack。拥有该设置意味着它回发并刷新控件,从而导致选择默认值。
答案 1 :(得分:0)
<asp:button Id=" btnConfigureAlerts" runat="Server" OnClientClick="ViewModelPopup2()"></asp:button>
function ViewModelPopup2() {
$("#ViewModalPopupDiv2").dialog({
scrollable: true,
width: 800,
modal: true
});
};