0
我使用ASP.NET从代码隐藏更改过程值?
我想在数据库工作时从代码隐藏中向用户显示百分比。
我想问题是在这里,当我从cs percentege调用这个函数工作精美!
protected void btnUpdate_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
但我真正的代码是连接数据库并插入300 - 1000行! 它工作时服务器光标图标变为忙图标,所以它冻结,我不能设置我的百分比值。
plz帮助...
我有一个Web服务:
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;
}
}
我在AjaxCall功能:
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);
}
}
});
}
我打电话的UpdateProgress按钮的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;
}
}
});
我的Cs动作代码 保护无效btnAction_Click(对象发件人,EventArgs的){
...
...
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);
...
...
}
thx我在尝试 – Mennan
我怎么能打电话给这个PageAsyncTask?它只有一个电话我无法想象它。我想每秒钟打电话给我,我该怎么做? – Mennan
您不希望每秒钟只调用一次PageAsyncTask。在我的答案中查看添加的注释。 –