Pages | Perform when a page executes longer, such as a large data query, and so on. You can use the following method to display prompts for the user.
Use case scenario:
Users to generate XML files to the National Bureau, and this amount of data is very large, query data for a while, write XML file also need a period of time, then how to give users a good hint that. If the escalation data is currently being analyzed. When the analysis is complete, prompt the user for "currently writing XML file", "currently compressing XML file", and so on. Give the user a hint when the server finishes a phase. Let the user know where they are. This will let the user know that there is no panic.
Call this method in the Page_Load method.
private void Loadplan ()
{
String loadtext= "Loading page, please wait patiently";
Response.Write ("<div id= ' mydiv ' width= ' 400px ' >");
Response.Write ("_");
Response.Write ("</div>");
Response.Write ("<script>mydiv.innertext = ';</script>");
Response.Write ("<script language=javascript>");
Response.Write ("var output = '" +loadtext+ ");
Response.Write ("var dots = 0;var Dotmax = 10;function showwait ()");
Response.Write ("{dots++;if (Dots>=dotmax) Dots=1;");
Response.Write ("for" (var x = 0;x < dots;x++) {output + = ' ▌ ';} Mydiv.innertext = output;} ");
Response.Write ("function startshowwait () {mydiv.style.visibility = ' visible '; Window.setinterval (' showwait () ', 1000);} ");
Response.Write ("function hidewait () {mydiv.style.visibility = ' hidden '; mydiv.style.display= ' none '; Window.clearinterval ();} ");
Response.Write ("startshowwait ();</script>");
Response.Flush ();
Thread.Sleep (10);
}
Call this method after a phase has finished executing
Title to the user tips
private void Updateplan (string title)
{
Response.Write ("<script language=javascript>");
Response.Write ("output = '" +title+ ");
Response.Write ("</script>");
Response.Flush ();
Thread.Sleep (10);
}
In the HTML page to have the following Dongdong!
<script language= "JavaScript" >
<!--
HideWait ();
-->
</script>
Example:
Start generating escalation files
private void Btnbuild_click (object sender, System.EventArgs e)
{
This. Updateplan ("You are querying the data required to report the file, this may take a while, please wait patiently!"); /Call
System.Data.DataSet Objs=this.buildobjs ();
if (objs==null) return;
LNPT. DataAccessLayer.SystemCommon.UpLoadDAL dal=new LNPT. DataAccessLayer.SystemCommon.UpLoadDAL ();
String Uploadtype=this. request.querystring["Uploadtype"];
String Path=this. GetPath ();
Path=path+this.txtversion.text+this.txtapp_cd. Text+system.datetime.now.tofiletime (). ToString () + ". xml";
This. Updateplan ("The XML escalation file is being generated, this may take some time, please wait patiently!"); /Call
Dal. buildXML (PATH,OBJS,UPLOADTYPE,THIS.TXTVERSION.TEXT,THIS.TXTAPP_CD. Text,txtsend_organ. Text,this.txtrece_organ. Text,this.txtcondition.text);
Add escalation file Build record
This. Updateplan ("compressing the generated XML escalation file, please wait patiently!"); /Call
Path=this. Createzipfile (path);
This. Addhistroy (path);
This. Bindhistroy ();
}