I have a button click function, which accomplished a series of task. I want to show and update a progressbar upon completion of each task lets say 25%, 50% and likewise, I am using jQuery progress bar to achieve this and using 4 hidden fields to store the different values but the progress bar doesnot grow as the function goes on it directly show 100% complete the code sample is as follows
<asp:Button ID="Button1" runat="server" Text="btnExecute" OnClientClick="return timeout_init();" OnClick="btnExecute_Click" />
codebehind: setting different hiddenfield values
protected void btnExecute_Click(object sender, EventArgs e)
{
//Ist level task complete
hfProgressValue.Value = "25";
Thread.Sleep(1000);
//IInd level task completion
ProgressValue1.Value = "50";
Thread.Sleep(1000);
//3rd level task
prg2.Value = "75";
Thread.Sleep(1000);
//4th level task
hfprg3.Value = "100";
}
javascript
function timeout_init() {
var progressBarVal = $("input[id$='hfProgressValue']").val();
var progressBarVal1 = $("input[id$='ProgressValue1']").val();
var progressBarVal2 = $("input[id$='prg2']").val();
var progressBarVal3 = $("input[id$='hfprg3']").val();
if (progressBarVal != "") {
$("#progressbar").progressbar({
value: parseInt(progressBarVal)
});
}
if (progressBarVal1 != "") {
$("#progressbar").progressbar({
value: parseInt(progressBarVal1)
});
}
if (progressBarVal2 != "") {
$("#progressbar").progressbar({
value: parseInt(progressBarVal2)
});
}
if (progressBarVal3 != "") {
$("#progressbar").progressbar({
value: parseInt(progressBarVal3)
});
}
setTimeout('timeout_init()', 0);
}