[英]How to popup a dialog box in Page Load
I have make a dialogbox as shown below in aspx:我在aspx中创建了一个如下所示的对话框:
<div id="IsAccountingOk" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a><br />
<asp:Label ID="lblIsAccountingOkHeader" runat="server" Text="Kassekladde:" Font-Size="Large"></asp:Label><br /><br />
<asp:Label ID="lblMessage" runat="server" Text="Der skal først vælges regnskabsår!"></asp:Label><br />
<br />
<asp:Button ID="btnIsAccountingOK" runat="server" Text="Ok" OnClick="btnIsAccountingOK_Click"/>
</div>
</div>
and styled as shown below:样式如下:
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity: 0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity: 1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover {
background: #00d9ff;
}
My question is: How can I popup this dialogbox by code behind in Page_Load - without making a click on a button by the user?我的问题是:如何通过 Page_Load 中的代码弹出此对话框 - 而无需用户单击按钮?
Maybe it can be done via JavaScript.也许它可以通过 JavaScript 来完成。
I have also tried the following in javascript:我也在 javascript 中尝试了以下内容:
$(document).ready(function () {
$('#IsAccountingOk').show();
});
But when I use the abovementioned method - everything on the DIV is blocked - and that was not the intention :-(但是当我使用上述方法时 - DIV 上的所有内容都被阻止 - 而这不是我的意图:-(
For further information I can tell that I have got it to work via a button as shown below:有关更多信息,我可以告诉我已经通过一个按钮使其工作,如下所示:
<asp:Button ID="btnIsAccountingOk" Text="Der skal først vælges et regnskabsår" runat="server" PostBackUrl="#IsAccountingOk"/><br />
Further information: I have added the following line i sitepage.master:更多信息:我在sitepage.master中添加了以下行:
<script type="text/javascript" src="scripts/jquery-3.3.1.js"></script>
And it has helped a lot.它帮助了很多。
But但
Thanks in advance.提前致谢。 Regards Michael问候迈克尔
There is not an event handler to handle when page is loading..页面加载时没有要处理的事件处理程序。
$(document).ready(function() {
//code here
});
You can use $(document).ready() it will run code when DOM is ready and it won't wait for window loaded(images,iframes...)您可以使用 $(document).ready() 它会在 DOM 准备好时运行代码,并且不会等待窗口加载(图像,iframes ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.