ProgressBar in WebApplication in C#

If you want to user progress bar on the click event for webapplication please refer ex. code.

Call the progress bar method in each sequence UpdateProgressBar;

like

UpdateProgressBar(0, msg, 1);

UpdateProgressBar(10, msg, 1);

public void UpdateProgressBar(decimal Text, string msg, int flage)

{

    if (flage == 1)

    {

        this.Page.Response.Write("<script>UpdateIndicator(\"" + Convert.ToInt32(Text).ToString() + "\",\"" + msg + "\");</script>");

        Response.Flush();

    }

}

public void progressBarJavaScript()

{

    StringBuilder sb = new StringBuilder();

    sb.Append("<table width=\"100%\" id=\"tblProcess\" border=\"0\" cellpadding =\"0\" cellspacing=\"0\"><tr><td align=\"center\"><table width=\"50%\" border=\"1\" style=\"font-family:Arial; font-size:12px;height:100px; background-color:Gray;filter:alpha(opacity=60); opacity:0.60; text-align:center\"><tr><td valign=\"top\"><div id=\"dvMethodMSG\" style=\"font-family: Arial; font-size: 12px; font-weight:bolder;color:White;\"></div> <img src=\"../images/loading.gif\" />" +

    "<table border=\"0\" style=\"font-family:Arial; font-size:12px;\" width=\"300px\"><tr><td width=\"100%\" style=\"text-align:center\"><div id=\"ProgressText\"style=\"font-family: Arial; font-size: 12px; font-weight:bolder;color:White;\">0%</div></td></tr></table>" +

    "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"400px\" height=\"15\"><tr><td id=\"indicator\" style=\"background-image:url('../images/ProgressBlue.jpg'); background-repeat:repeat-x\" width=\"0%\"></td><td width=\"100%\"></td></tr></table></td></tr></table></td></tr></table>");

 

    //// Insert the scripts for updating

    sb.Append("<script language=javascript>;");

    sb.Append("function ShowProgress(){}");

    sb.Append("function StartShowWait(){ window.setInterval('ShowProgress()',1000);}");

    sb.Append("function HideWait(){window.clearInterval();}");

    sb.Append("function UpdateIndicator(NewValue,msg) {indicator.style.width = NewValue +\"%\"; ProgressText.innerText=NewValue + \"%\"; dvMethodMSG.innerText=msg;if (((msg==\"Please wait. Saving of parsed data into an Excel file is in progress.\") || (msg==\"Please wait. Saving of data to database in progress.\")) && (NewValue==\"100\")){tblProcess.style.display = 'none';}}");

    sb.Append("StartShowWait();</script>");

    this.Page.Response.Write(sb.ToString());

}

Ebook Download
View all
Learn
View all