【问题标题】:Pause the processing of saving the data when modal popup show模态弹窗显示时暂停保存数据的处理
【发布时间】:2013-01-25 09:12:28
【问题描述】:

当模态弹出窗口显示时,如何暂停保存数据的处理? 当我单击该模式弹出窗口内的按钮时,保存数据的执行将继续处理。

我的模态弹出窗口就像一个消息框...

这是我的示例代码:

bool overlap= false;
foreach (ListItem item in chkMBoxEmployeeList.Items)
{
    if (overlap == true)
    {
      //Saving of data 
    }
    else if (overlap == false)
    {
       ModalpopupExtender2.Show();
       //In this condition, I will pause the execution of saving the data
    }
}

//I used this after the ModalpopupExtender2.Show():
return;

//but I think, this will not be the answer, because my code will become very long if use that.  I will rewrite again my code in the button in modalpopup if I use that.

我应该使用线程吗? Threading 是否在 ASP.Net 上工作?

【问题讨论】:

标签: c# asp.net multithreading modalpopupextender


【解决方案1】:

您的保存过程正在服务器上进行,但模式对话框将显示在客户端上。您不能让服务器等待浏览器中的用户响应。相反,服务器处理必须结束并将修改后的页面发送到浏览器。现在浏览器将再次提交所有数据以及确认。由于您使用的是 ASP.NET WebForms,因此您很幸运,因为它会自动处理此类场景的状态。

public void Save(bool confirmed)
{
    if (!confirmed && NeedsConfirmation())
    {
        ShowModalWindow();
        return;
    }

    // here perform the operation.
}

public void ButtonSave_Click(object sender, EventArgs e)
{
    // this is the button that is normally displayed on the form
    this.Save(false);
}

public void ButtonConfirm_Click(object sender, EventArgs e)
{
    // this button is located within the modal dialog - so it is not shown before that.
    this.Save(true);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 2017-04-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多