C# 在c中加载页面时显示加载图像#
我需要在c#中加载页面时显示加载图像 我尝试使用此解决方案但未成功,因为错误是:C# 在c中加载页面时显示加载图像#,c#,C#,我需要在c#中加载页面时显示加载图像 我尝试使用此解决方案但未成功,因为错误是: Line 72: this.Response.Write(@"dots++;"); 我将非常感谢你在解决这个问题上给我的任何帮助 这是我的密码: <script runat="server"> private void Page_Load(object sender, System.EventArgs e) { PleaseWait();
Line 72: this.Response.Write(@"dots++;");
我将非常感谢你在解决这个问题上给我的任何帮助
这是我的密码:
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
PleaseWait();
}
protected void PleaseWait()
{
this.Response.Write("<meta http-equiv=X-UA-Compatible content=IE=8>");
this.Response.Write(@"<style type=text/css media=all>");
this.Response.Write(@".loading");
this.Response.Write(@"{");
this.Response.Write(@"text-align: center;");
this.Response.Write(@"padding-top: 30px;");
this.Response.Write(@"border-width: 1px solid #000;");
this.Response.Write(@"width: 300px;");
this.Response.Write(@"height: 100px;");
this.Response.Write(@"-ms-filter: alpha(opacity=90);");
this.Response.Write(@"-ms-opacity: 0.90;");
this.Response.Write(@"border-style: solid;");
this.Response.Write(@"background-color: #FFFFFF;");
this.Response.Write(@"position: absolute;");
this.Response.Write(@"font-family: Trebuchet MS;");
this.Response.Write(@"font-size: small;");
this.Response.Write(@"position: absolute;");
this.Response.Write(@"top: 0;");
this.Response.Write(@"bottom: 0;");
this.Response.Write(@"left: 0;");
this.Response.Write(@"right: 0;");
this.Response.Write(@"margin: auto;");
this.Response.Write(@"display: block;");
this.Response.Write(@"background: url('/images/wait01.gif') no-repeat center;");
this.Response.Write(@"}");
this.Response.Write(@"</style>");
this.Response.Write(@"<div id=mydiv class=loading> </div>");
this.Response.Write(@"<script>mydiv.innerText = '';");
this.Response.Write(@"</script>");
this.Response.Write(@"<script type=text/javascript language="javascript">;");
this.Response.Write(@"var dots = 0;");
this.Response.Write(@"var dotmax = 10;");
this.Response.Write(@"function ShowWait()");
this.Response.Write(@"{");
this.Response.Write(@"var output;");
this.Response.Write(@"output = '" + "Please wait..." + "';");
this.Response.Write(@"dots++;");
this.Response.Write(@"if(dots>=dotmax)dots=1;");
this.Response.Write(@"for(var x = 0;");
this.Response.Write(@"x < dots;x++)");
this.Response.Write(@"{");
this.Response.Write(@"output += '.';");
this.Response.Write(@"}");
this.Response.Write(@"mydiv.innerText = output;");
this.Response.Write(@"}");
this.Response.Write(@"function StartShowWait()");
this.Response.Write(@"{");
this.Response.Write(@"mydiv.style.visibility = 'visible'; ");
this.Response.Write(@"window.setInterval('ShowWait()',1000);");
this.Response.Write(@"}");
this.Response.Write(@"function HideWait()");
this.Response.Write(@"{");
this.Response.Write(@"mydiv.style.visibility = 'hidden';");
this.Response.Write(@"window.clearInterval();");
this.Response.Write(@"}");
this.Response.Write(@"StartShowWait();");
this.Response.Write(@"</script>");
this.Response.Flush();
System.Threading.Thread.Sleep(500);
}
</script>
私有无效页面加载(对象发送方,System.EventArgs e)
{
请用它();
}
受保护的void-it()
{
这个.Response.Write(“”);
这个.Response.Write(@“”);
这个.Response.Write(@.loading”);
this.Response.Write(@“{”);
this.Response.Write(@“text align:center;”);
this.Response.Write(@“padding top:30px;”);
this.Response.Write(@“边框宽度:1px实心#000;”);
this.Response.Write(@“宽度:300px;”);
this.Response.Write(@“高度:100px;”);
this.Response.Write(@“-ms过滤器:alpha(不透明度=90);”;
this.Response.Write(@“-ms不透明度:0.90;”);
this.Response.Write(@“border style:solid;”);
this.Response.Write(@“背景色:#FFFFFF;”);
this.Response.Write(@“位置:绝对;”);
this.Response.Write(@“字体系列:Trebuchet MS;”);
this.Response.Write(@“font size:small;”);
this.Response.Write(@“位置:绝对;”);
this.Response.Write(@“top:0;”);
this.Response.Write(@“bottom:0;”);
this.Response.Write(@“left:0;”);
this.Response.Write(@“right:0;”);
this.Response.Write(@“margin:auto;”);
this.Response.Write(@“display:block;”);
this.Response.Write(@“background:url('/images/wait01.gif')无重复中心;”;
this.Response.Write(@“}”);
这个.Response.Write(@“”);
这个.Response.Write(@“”);
this.Response.Write(@“mydiv.innerText=“”;”);
这个.Response.Write(@“”);
这个.Response.Write(@“;”);
this.Response.Write(@“var dots=0;”);
this.Response.Write(@“var dotmax=10;”);
this.Response.Write(@“function ShowWait()”);
this.Response.Write(@“{”);
this.Response.Write(@“var output;”);
this.Response.Write(@“output=”+“请稍候…”+“;”);
this.Response.Write(@“dots++;”);
this.Response.Write(@“if(dots>=dotmax)dots=1;”;
this.Response.Write(@“for(var x=0;”);
this.Response.Write(@“x
我猜您希望在页面加载时显示加载图像
如果是这种情况,您可以使用Jquery加载事件来显示加载图像
试试这个:使用响应。这样写太疯狂了!你可以这样做,并在过程中保持你的头发是: html
<body class="load">
<p>My hair is still here.</p>
</body>
js
.load{
background-color:#e6e6e6;
}
.load.complete{
background-color:transparent;
}
$(document).ready(function(){
this.body.className = 'load complete';
})
这里有一个非常简单的例子。只是。。。否。删除所有
响应。写入,像预期的那样使用ASP.NET(使用控件,而不是响应。写入),并让浏览器显示它正在加载。或者再解释一下,你实际上犯了什么错误:不,你不想这样做。在加载页面时,也不能在页面上显示加载图像,因为需要加载页面才能显示图像。