What I am trying to achieve is : when a file is downloaded from FTP server it should add 2% to bootstrap progress-bar.
C# code is ok and files get downloaded but the progress-bar is stuck at 2%.
HTML and Javascript is ok and working, but when called from code behind it's executed only once. i.e. bootstrap progress-bar moves only to 2%.
C#
int count=2;
using (WebClient ftpClient = new WebClient())
{
ftpClient.Credentials = new System.Net.NetworkCredential("win10", "zzzz");
for (int i = 0; i <= directories.Count - 1; i++)
{
if (directories[i].Contains("."))
{
string path = "ftp://192.168.0.120/" + directories[i].ToString();
string trnsfrpth = @"E:\\ProjectLocalPath\" + directories[i].ToString();
ftpClient.DownloadFile(path, trnsfrpth);
ClientScript.RegisterStartupScript(this.GetType(), "lol", "javascript: updateProgress('" + count2 + "')", true);
count2 += 2;
}
}
}
HTML
<div id="div3" runat="server" class="progress progress-danger progress-striped progress progress_sm active" style="width: 425%;">
<div id="e3" style="width: 0%;" class="bar" runat="server" role="progressbar">
</div>
</div>
Javascript
var _prevent;
var percentage;
function updateProgress(percentage) {
_prevent = setInterval(function () {
var $bar = $('.bar');
if (percentage > 100) {
percentage = 100;
clearInterval(_prevent);
}
$bar.width(percentage);
$bar.text(percentage + "%");
},800);
}
window.clearInterval(_prevent);