我有一个登陆页面:我是这样用它的,肯定错了。如何用?
private void Page_Load(object sender, System.EventArgs e)
{
showProgress();//WEB应用程序中的进度条 if(!IsPostBack)
{
loginbtn.Attributes.Add("onmouseover","this.src='images/logindown.gif'");
loginbtn.Attributes.Add("onmouseout","this.src='images/login.gif'");
}
}
private void loginbtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
string script = @"<script language='javascript'>"
+"\r"
+"window.opener=null;window.close();var Win = window.open('Webui/main.aspx','main','fullscreen=yes');\r"
+"Win.moveTo(0,0);\r"
+"Win.resizeTo(screen.width,(screen.height-25));\r"
+"</script>";
Response.Write(script);
}
private void showProgress()
{
string strFileName = Path.Combine( Server.MapPath("./Progress"), "progressbar.htm" );
StreamReader sr = new StreamReader( strFileName, System.Text.Encoding.Default );
string strHtml = sr.ReadToEnd();
Response.Write( strHtml );
sr.Close();
Response.Flush();
Thread thread = new Thread( new ThreadStart(ThreadProc) );
thread.Start();
thread.Join();
}
private void ThreadProc()
{
//其中的{0}会被相应的i替换,而该段脚本会调用预先写好的javascript函数setPgb,更改页面的进度条状态。
string strScript = "<script>setPgb('pgbMain','{0}');</script>";
for ( int i = 0; i <= 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i ) );
Response.Flush();
}
}
private void Page_Load(object sender, System.EventArgs e)
{
showProgress();//WEB应用程序中的进度条 if(!IsPostBack)
{
loginbtn.Attributes.Add("onmouseover","this.src='images/logindown.gif'");
loginbtn.Attributes.Add("onmouseout","this.src='images/login.gif'");
}
}
private void loginbtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
string script = @"<script language='javascript'>"
+"\r"
+"window.opener=null;window.close();var Win = window.open('Webui/main.aspx','main','fullscreen=yes');\r"
+"Win.moveTo(0,0);\r"
+"Win.resizeTo(screen.width,(screen.height-25));\r"
+"</script>";
Response.Write(script);
}
private void showProgress()
{
string strFileName = Path.Combine( Server.MapPath("./Progress"), "progressbar.htm" );
StreamReader sr = new StreamReader( strFileName, System.Text.Encoding.Default );
string strHtml = sr.ReadToEnd();
Response.Write( strHtml );
sr.Close();
Response.Flush();
Thread thread = new Thread( new ThreadStart(ThreadProc) );
thread.Start();
thread.Join();
}
private void ThreadProc()
{
//其中的{0}会被相应的i替换,而该段脚本会调用预先写好的javascript函数setPgb,更改页面的进度条状态。
string strScript = "<script>setPgb('pgbMain','{0}');</script>";
for ( int i = 0; i <= 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i ) );
Response.Flush();
}
}
<head>
<link rel="stylesheet" type="text/css" href="common.css">
<script language="javascript">
function setPgb(pgbID, pgbValue)
{
if ( pgbValue <= 100 )
{
if (lblObj = document.getElementById(pgbID+'_label'))
{
lblObj.innerHTML = pgbValue + '%'; // change the label value
}
if ( pgbObj = document.getElementById(pgbID) )
{
var divChild = pgbObj.children[0];
pgbObj.children[0].style.width = pgbValue + "%";
}
window.status = "数据读取" + pgbValue + "%,请稍候...";
}
if ( pgbValue == 100 )
window.status = "数据读取已经完成";
}
</script>
</head>
<body bgColor="buttonface" topmargin="0" leftmargin="0">
<table width="100%" height="100%" ID="Table1">
<tr>
<td align="center" valign="middle">
<DIV class="bi-loading-status" id="proBar" style="LEFT: 425px; TOP: 278px"><FONT face="宋体"></FONT>
<DIV class="text" id="pgbMain_label" align="left"></DIV>
<DIV class="progress-bar" id="pgbMain" align="left">
<DIV STYLE="WIDTH:10%"></DIV>
</DIV>
</DIV>
</td>
</tr>
</table>
</body>
</html>
在实际项目中可以根据后台程序执行的进度往前端发送脚本To:IamBird(IamBird)
不可能的吧,我已经运行正常,没有问题的,把你的代码贴出来我看看吧