![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
protected void AddProgressBar()
{
try
{
string s = ((LiteralControl)Controls[0]).Text;
}
catch
{
return;
}
// 修改记录1
// 是否显示进度条
if (ShowProgressBar == true)
{
//this.RegisterOnSubmitStatement("Submit","ToSubmit();");
string script = @"<!--
var ie5 = (document.all&&document.getElementsByTagName);
function setProgress(v, el)
{
if (ie5 || document.readyState == ""complete"")
{
filterEl = el.children[0];
valueEl = el.children[1];
if (filterEl.style.pixelWidth > 0)
{
var filterBackup = filterEl.style.filter;
filterEl.style.filter = """";
filterEl.style.filter = filterBackup;
}
filterEl.style.width = v + ""%"";
valueEl.innerText=v+ ""%"";
}
}
var step=1;
var ProgressStart=false;
var ProgressNum=0;
var WaitTime=10;
var OnSubmit = false;
function fakeProgress(el)
{
if (ProgressNum >= 99)
{
setProgress(99, el);
}
else
{
if(step>=100)
{
return;
}
setProgress(ProgressNum, el);
ProgressNum++;
if(ProgressNum>60)
{
WaitTime=WaitTime+10;
}
else if(ProgressNum>85)
{
WaitTime=WaitTime+100;
}
else if(ProgressNum>90)
{
WaitTime=WaitTime+ProgressNum;
}
else if(ProgressNum>95)
{
WaitTime=WaitTime+ProgressNum;
}
window.setTimeout(""fakeProgress(document.all[\'"" + el.id + ""\'])"", WaitTime);
}
}
function showProgress()
{
try{Form1.style.display='none';}catch(ex){}
if(ProgressStart==true){WaitTime=50;ProgressNum=0;return;}
window.document.all.ProgressPanle.style.display="""";
ProgressStart=true;
fakeProgress(window.document.all.Progress);
}
window.onbeforeunload=showProgress;
function overProgress(){
step=100;setProgress(100, window.document.all.Progress);
window.setTimeout(""setProgress(100, window.document.all.Progress)"", 0);
}
// window.onunload=overProgress;
//--> ";
string JavaScriptStr = @"<SCRIPT type=""text/javascript""> ";
JavaScriptStr += script + @"</SCRIPT>";
string HideFormTable = @"<div id=""ProgressPanle"" style=""LEFT: 35%;TOP: 45%;DISPLAY: none; POSITION: absolute;WIDTH: 30%; "" border=0>
<font style=""FONT-SIZE: 9pt; COLOR: black; HEIGHT: 10px"">正在处理中...</font>
<div id=""Progress"" style=""BORDER: darkgray 1px solid; BACKGROUND: white; WIDTH: 100%;HEIGHT: 16px; TEXT-ALIGN: left"">
<div id=""sbChild1"" style=""FILTER: Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=0); WIDTH: 0%; POSITION: absolute; HEIGHT: 14px"">
<div style=""FONT-SIZE: 1px; BACKGROUND: highlight; WIDTH: 100%; HEIGHT: 100%;""></div>
</div>
<div style=""FONT-SIZE: 12px; WIDTH: 100%; COLOR: silver; FONT-FAMILY: arial; POSITION: absolute; TEXT-ALIGN: center"">0%</div>
</div> </div>";
((LiteralControl)Controls[0]).Text += HideFormTable;
((LiteralControl)Controls[Controls.Count - 1]).Text += JavaScriptStr;
}
}
{
try
{
string s = ((LiteralControl)Controls[0]).Text;
}
catch
{
return;
}
// 修改记录1
// 是否显示进度条
if (ShowProgressBar == true)
{
//this.RegisterOnSubmitStatement("Submit","ToSubmit();");
string script = @"<!--
var ie5 = (document.all&&document.getElementsByTagName);
function setProgress(v, el)
{
if (ie5 || document.readyState == ""complete"")
{
filterEl = el.children[0];
valueEl = el.children[1];
if (filterEl.style.pixelWidth > 0)
{
var filterBackup = filterEl.style.filter;
filterEl.style.filter = """";
filterEl.style.filter = filterBackup;
}
filterEl.style.width = v + ""%"";
valueEl.innerText=v+ ""%"";
}
}
var step=1;
var ProgressStart=false;
var ProgressNum=0;
var WaitTime=10;
var OnSubmit = false;
function fakeProgress(el)
{
if (ProgressNum >= 99)
{
setProgress(99, el);
}
else
{
if(step>=100)
{
return;
}
setProgress(ProgressNum, el);
ProgressNum++;
if(ProgressNum>60)
{
WaitTime=WaitTime+10;
}
else if(ProgressNum>85)
{
WaitTime=WaitTime+100;
}
else if(ProgressNum>90)
{
WaitTime=WaitTime+ProgressNum;
}
else if(ProgressNum>95)
{
WaitTime=WaitTime+ProgressNum;
}
window.setTimeout(""fakeProgress(document.all[\'"" + el.id + ""\'])"", WaitTime);
}
}
function showProgress()
{
try{Form1.style.display='none';}catch(ex){}
if(ProgressStart==true){WaitTime=50;ProgressNum=0;return;}
window.document.all.ProgressPanle.style.display="""";
ProgressStart=true;
fakeProgress(window.document.all.Progress);
}
window.onbeforeunload=showProgress;
function overProgress(){
step=100;setProgress(100, window.document.all.Progress);
window.setTimeout(""setProgress(100, window.document.all.Progress)"", 0);
}
// window.onunload=overProgress;
//--> ";
string JavaScriptStr = @"<SCRIPT type=""text/javascript""> ";
JavaScriptStr += script + @"</SCRIPT>";
string HideFormTable = @"<div id=""ProgressPanle"" style=""LEFT: 35%;TOP: 45%;DISPLAY: none; POSITION: absolute;WIDTH: 30%; "" border=0>
<font style=""FONT-SIZE: 9pt; COLOR: black; HEIGHT: 10px"">正在处理中...</font>
<div id=""Progress"" style=""BORDER: darkgray 1px solid; BACKGROUND: white; WIDTH: 100%;HEIGHT: 16px; TEXT-ALIGN: left"">
<div id=""sbChild1"" style=""FILTER: Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=0); WIDTH: 0%; POSITION: absolute; HEIGHT: 14px"">
<div style=""FONT-SIZE: 1px; BACKGROUND: highlight; WIDTH: 100%; HEIGHT: 100%;""></div>
</div>
<div style=""FONT-SIZE: 12px; WIDTH: 100%; COLOR: silver; FONT-FAMILY: arial; POSITION: absolute; TEXT-ALIGN: center"">0%</div>
</div> </div>";
((LiteralControl)Controls[0]).Text += HideFormTable;
((LiteralControl)Controls[Controls.Count - 1]).Text += JavaScriptStr;
}
}