[Csharp]
Protected void button#click (object sender, EventArgs e)
{
ShowLoading ("Searching ...");
}
Protected void Button2_Click (object sender, EventArgs e)
{
RemoveLoading ();
}
# Region data loading progress bar
/// <Summary>
/// Display the page loading effect
/// </Summary>
Public void ShowLoading (string msg)
{
StringBuilder s = new StringBuilder ();
S. Append ("<script language = JavaScript type = text/javascript> \ n ");
S. Append ("var t_id = setInterval (animate, 20); \ n ");
S. Append ("var pos = 0; var dir = 2; var len = 0; \ n ");
S. Append ("function animate () {\ n ");
S. Append ("var elem = document. getElementById ('progress'); \ n ");
S. Append ("if (elem! = Null) {\ n ");
S. Append ("if (pos = 0) len + = dir; \ n ");
S. Append ("if (len> 32 | pos> 79) pos ++ = dir; \ n ");
S. Append ("if (pos> 79) len-= dir; \ n ");
S. Append ("if (pos> 79 & len = 0) pos = 0; \ n ");
S. Append ("elem. style. left = pos; \ n ");
S. Append ("elem. style. width = len; \ n ");
S. Append ("}}\ n ");
S. Append ("function removeLoadMsg () {\ n ");
S. Append ("this. clearInterval (t_id); \ n ");
S. Append ("var targelem = document. getElementById ('loader _ iner '); \ n ");
S. Append ("targelem. style. display = 'none'; \ n ");
S. Append ("targelem. style. visibility = 'den den '; \ n ");
S. Append ("} \ n ");
S. Append ("</script> \ n ");
S. Append ("<style> ");
S. Append ("# loader_container {text-align: center; position: absolute; top: 40%; width: 100%; left: 0 ;}\ n ");
S. append ("# loader {font-family: Tahoma, Helvetica, sans; font-size: 11.5px; color: #000000; background-color: # FFFFFF; padding: 10px 0 16px 0; margin: 0 auto; display: block; width: 130px; border: 1px solid # 5a667b; text-align: left; z-index: 9999 ;} \ n "); www.2cto.com
S. append ("# progress {height: 5px; font-size: 1px; width: 1px; position: relative; top: 1px; left: 0px; background-color: #8894a8 ;} \ n ");
S. append ("# loader_bg {background-color: # e4e7eb; position: relative; top: 8px; left: 8px; height: 7px; width: 113px; font-size: 1px ;} \ n ");
S. Append ("</style> \ n ");
S. Append ("<div id = loader_container> \ n ");
S. Append ("<div id = loader> \ n ");
S. Append ("<div align = center>" + msg + "</div> \ n ");
S. Append ("<div id = loader_bg> <div id = progress> </div> \ n ");
S. Append ("</div> \ n ");
// HttpContext. Current. Response. Write (s. ToString ());
HttpContext. Current. Response. Write (s. ToString ());
HttpContext. Current. Response. Flush ();
}
Public void RemoveLoading ()
{
ClientScript. RegisterClientScriptBlock (typeof (string), "", "<script> removeLoadMsg (); </script> ");
} # Endregion