在页面加载时显示弹出窗口并在asp.net C中单击面板外部时消失 [英] Display popup in page load and disappear when click outside the panel in asp.net C#
本文介绍了在页面加载时显示弹出窗口并在asp.net C中单击面板外部时消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望 显示popup 在页加载 和它应该消失当我点击 asp.net中的弹出式面板之外。
我已经尝试过这个javascript但它的工作喜欢 当我点击按钮弹出时会显示和 当我在面板外单击时弹出窗口将消失。
< style type = text / css>
body
{
font-family:Arial;
字体大小:10pt;
}
.modalBackground
{
background-color:Black;
filter:alpha(opacity = 60);
opacity: 0 。 6 ;
}
.modalPopup
{
background-color:#FFFFFF;
宽度:300px;
border:3px solid#0DA9D0;
填充: 0 ;
}
.modalPopup .header
{
background-color:#2FBDF1;
身高:30px;
颜色:白色;
行高:30px;
text-align:center;
font-weight:bold;
}
.modalPopup .body
{
min-height:50px;
行高:30px;
text-align:center;
font-weight:bold;
margin-bottom:5px;
}
< / style>
< script type = text / javascript>
function pageLoad(){
var modalPopup = $ find (' mpe');
modalPopup.add_shown( function (){
modalPopup._backgroundElement.addEventListener( 点击, function (){
modalPopup.hide();
});
});
};
< / script>
< body>
< asp:Button ID = btnShow runat = server Text = 按钮 />
< asp:Panel ID = pnlPopup runat = server BackColor = LightBlue BorderColor = 红色 style = display:none
Width = 466px高度= 400px>
< asp:按钮ID = btn runat = server Text = 按钮 />
< cc1:ModalPopupExtender ID = ModalPopupExtender1 BehaviorID = mpe runat = server
PopupControlID = pnlPopup TargetControlID = btnShow BackgroundCssClass = < span class =code-string> modalBackground>
< / body>
请帮我
谢谢 advance
解决方案
find (' mpe');
modalPopup.add_shown( function (){
modalPopup._backgroundElement.addEventListener( 点击, function (){
modalPopup.hide();
});
});
};
< / script>
< body>
< asp:Button ID = btnShow runat = server Text = 按钮 />
< asp:Panel ID = pnlPopup runat = server BackColor = LightBlue BorderColor = 红色 style = display:none
Width = 466px高度= 400px>
< asp:按钮ID = btn runat = server Text = 按钮 />
< cc1:ModalPopupExtender ID = ModalPopupExtender1 BehaviorID = mpe runat = server
PopupControlID = pnlPopup TargetControlID = btnShow BackgroundCssClass = < span class =code-string> modalBackground>
< / body>
请帮助我
谢谢 advance
在您的标记上方添加
< script type = 文本/ JavaScript的跨度>>
pageLoad();
< / script>
或者将函数绑定到window.onload或
< blockquote>(document).ready如果你正在使用jQuery。
你做了正确的方法,你只是在点击之前不在任何地方调用它。
Hi,
I want to display popup in page load and it should get disappear when i click outside that popup panel in asp.net.
I have tried this javascript but its working like when i click button popup will display and when i click outside the panel popup will disappear.
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.modalBackground
{
background-color: Black;
filter: alpha(opacity=60);
opacity: 0.6;
}
.modalPopup
{
background-color: #FFFFFF;
width: 300px;
border: 3px solid #0DA9D0;
padding: 0;
}
.modalPopup .header
{
background-color: #2FBDF1;
height: 30px;
color: White;
line-height: 30px;
text-align: center;
font-weight: bold;
}
.modalPopup .body
{
min-height: 50px;
line-height: 30px;
text-align: center;
font-weight: bold;
margin-bottom: 5px;
}
</style>
<script type="text/javascript">
function pageLoad() {
var modalPopup = $find('mpe');
modalPopup.add_shown(function () {
modalPopup._backgroundElement.addEventListener("click", function () {
modalPopup.hide();
});
});
};
</script>
<body>
<asp:Button ID="btnShow" runat="server" Text="Button" />
<asp:Panel ID="pnlPopup" runat="server" BackColor = "LightBlue" BorderColor= "Red" style="display:none"
Width="466px" Height="400px">
<asp:Button ID="btn" runat="server" Text="Button" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server"
PopupControlID="pnlPopup" TargetControlID="btnShow" BackgroundCssClass="modalBackground">
</body>
please help me
thanks in advance
解决方案
find('mpe'); modalPopup.add_shown(function () { modalPopup._backgroundElement.addEventListener("click", function () { modalPopup.hide(); }); }); }; </script> <body> <asp:Button ID="btnShow" runat="server" Text="Button" /> <asp:Panel ID="pnlPopup" runat="server" BackColor = "LightBlue" BorderColor= "Red" style="display:none" Width="466px" Height="400px"> <asp:Button ID="btn" runat="server" Text="Button" /> <cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server" PopupControlID="pnlPopup" TargetControlID="btnShow" BackgroundCssClass="modalBackground"> </body> please help me thanks in advance
Just above your tag add
<script type="text/javascript"> pageLoad(); </script>
Or bind the function to window.onload or
(document).ready if you're using jQuery.
You made the correct method, you're just not calling it anywhere until you click.
这篇关于在页面加载时显示弹出窗口并在asp.net C中单击面板外部时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文