I use ASP.NET
I want to show percentage to user from codebehind while database working .
I think problem is here,when i call this function from cs percentege WORKS FINE!
protected void btnUpdate_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
But my real code is connect a database and insert 300 - 1000 rows !! When it works server cursor icon changed to busy icon,so it frozen and i cant set my percentage value.
Plz Help...
I got a webservice :
public double CommittedCount = 0;
[WebMethod]
public string ShowPercentage()
{
return ((CommittedCount / FinishCount) * 100 ).ToString();
}
[WebMethod]
public void SetCommittedCount(double committedCount)
{
CommittedCount = committedCount;
}
public double FinishCount
{
get
{
if(Glob.ExcelDataSet.Tables[0].Rows.Count > 0)
return Glob.ExcelDataSet.Tables[0].Rows.Count;
return 1;
}
}
I got an ajaxcall function:
function updateProgress() {
$.ajax({
type: "POST",
url: '<%=ResolveUrl("~/processCalculator.asmx/ShowPercentage") %>',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
// TODO: revert the line below in your actual code
//$("#progressbar").progressbar("option", "value", msg.d);
$(".percentage").text(msg.d);
if (msg.d < 100) {
setTimeout(updateProgress, 100);
}
}
});
}
I called updateProgress button onclick:
<asp:Button Text="Sorgula" ID="btnAction" class="button_action" OnClick="Action_Click" Width="80px" runat="server" />
$(".button_action").click(function () {
var action_ = $(this).attr("value");
var ExcelRowCount = $('#<%=ExcelActionsIsAvaibleRowCount.ClientID %>').val();
if (ExcelRowCount != "") {
if (confirm(ExcelRowCount + " kayıt için [" + action_ + "] aksiyonu gerçekleştirilecek?")) {
setTimeout(updateProgress, 100);
return true;
}
else
{
return false;
}
}
});
My Cs Action Code protected void btnAction_Click(object sender, EventArgs e) {
...
...
for (int rowIndex = 1; rowIndex < Glob.ExcelDataSet.Tables[0].Rows.Count; rowIndex++)
{
...
...
aksiyon_sonucu_ = action.InsertRow(
Glob.ExcelDataSet.Tables[0].Rows[rowIndex], DegistirilebilirKolonlar, true);
// my persentage
processCalculater pCal = new processCalculater();
pCal.SetCommittedCount(rowIndex);
...
...
}