[英]How to diplay a popup window when changing the selected value in a dropdown list?
I want to display a popup window when I select a specific value from drop-down list. 当我从下拉列表中选择特定值时,我想显示一个弹出窗口。 But I don't have any idea to do it as I want. 但是我不知道要做什么。 I little example would be enough for this. 我为此举一个小例子。 For the pop up I expect to use panel. 对于弹出窗口,我希望使用面板。
It's pretty simple.Use SelectedIndexChanged
event of dropdownlist 很简单,使用dropdownlist的SelectedIndexChanged
事件
.aspx .aspx
<asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" Enabled="false" PopupControlID="PanelMonthly" TargetControlID="ddlfeegroup">
.cs .cs
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
ModalPopupExtender2.Enabled = true;
ModalPopupExtender2.Show();//popup show
}
on close button event again make ModalPopupExtender2.Enabled = false; 在关闭按钮事件上再次使ModalPopupExtender2.Enabled = false; or onclienclick of close button disable it 或关闭按钮的onclienclick禁用它
Hope this will work 希望这会起作用
<asp:HiddenField ID="hidForModel" runat="server" />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"></asp:DropDownList>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- ModalPopupExtender -->
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="hidForModel"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" Style="display: none">
<asp:Button ID="btnClose" runat="server" Text="Close" />
</asp:Panel>
<!-- ModalPopupExtender -->
.cs code .cs代码
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
mp1.Show();
}
css 的CSS
<style type="text/css">
.modalBackground {
background-color: Black;
filter: alpha(opacity=90);
opacity: 0.8;
}
.modalPopup {
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
width: 300px;
height: 140px;
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.