gpt4 book ai didi

javascript - 如何在 asp.net 4 中的 page_load 事件之前显示加载图像?

转载 作者:行者123 更新时间:2023-11-28 15:22:33 25 4
gpt4 key购买 nike

我需要显示加载图像,直到从数据库中获取数据并绑定(bind)到数据网格。我在父页面 (A.aspx) 中有一个按钮,当我们单击该按钮时,它将在叠加层中显示数据(B.aspx)。我们已经使用 greybox 在叠加层中显示页面。我已将加载图像放在 B.aspx 中

数据网格中数据的获取和显示在 Page_Load 中处理。由于所有逻辑都在 page_load 中处理,因此元素在 DOM 中不可用。

我无法显示/隐藏加载图像。

注意:我曾尝试在父页面 (A.aspx) 中放置相同的加载图像。但是加载图像显示在叠加层后面。

请找出这段代码:

protected void Page_Load(object sender, EventArgs e)
{
try
{
throbberSplashOverlay.Visible = true;
}
}





#ctl00_CPSContentHolder_throbberSplashOverlay
{
background-color:White;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 500;
}
#throbberSplash
{
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 1000;
background: url(../App_Themes/Blue/images/indicator.gif) no-repeat center center;
}



<div id="throbberSplashOverlay" runat="server" visible="false"><div id="throbberSplash"></div></div>

最佳答案

据我了解,您在 b.aspx 中显示数据。因此在 b.aspx 中使用 javascript 函数。onbeforeunload 用于 IE。
编辑:第一次加载页面时,您无法调用 javascript 函数,直到页面完全加载。因此在 div 中显示等待图像。并隐藏整个页面,直到页面完全加载。第二次您可以使用 onunload 或 onbeforeunload事件。

<html>
<head>
<script>
</script>

</head>
<body onunload="doHourglass();" onbeforeunload="doHourglass();" onload="show();">
<div id="divWait" style="display:inline" >
<h1>wait...</h1>
</div>

<div id="main" style="display:none">
<input type="button" onClick="call your method" />
//your rest of the html
<div/>

<script>
function doHourglass()
{
console.log("inside dohour glass");
var divwait=document.getElementById('divWait');
var divmainpage=document.getElementById('main');
divmainpage.style.zIndex="0";
divwait.style.zIndex="1";
divwait.style.display='inline';
divmainpage.style.display='none';
}

function show()
{
console.log("inside show");
var divwait=document.getElementById('divWait');
var divmainpage=document.getElementById('main');
divmainpage.style.zIndex="1";
divwait.style.zIndex="0";
divwait.style.display='none';
divmainpage.style.display='inline';
}

</script>
</body>
</html>

关于javascript - 如何在 asp.net 4 中的 page_load 事件之前显示加载图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32330553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com