c# - 模态弹出显示时暂停保存数据的处理

标签 c# asp.net multithreading modalpopupextender

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

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

这是我的示例代码:

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 上运行?

最佳答案

您的保存过程正在服务器 上进行,但模态对话框将显示在客户端 上。您不能让服务器等待浏览器中的用户响应。相反,服务器处理必须结束并将修改后的页面发送到浏览器。现在浏览器将再次提交所有数据和确认。由于您使用的是 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);
}

关于c# - 模态弹出显示时暂停保存数据的处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14518628/

相关文章:

ASP.NET MVC 多线程

c# - XNA 2D Basic 碰撞列表

c# - jQuery 1.11.3 Post 收到错误请求但不会失败

multithreading - 事件调度线程绘画

c# - 在 aspx 页面中使用哪个事件来读取 POSTed 数据?

javascript - 将我的 jquery 与 onclick 事件混合,该事件也与 SelectedIndexChanged 事件相关

c - 单线程如何完成多线程的工作?

c# - 如何在 UpdatePanel 中回发后保留 TinyMCE

c# - 我想使用 asp.net mvc 5 将 ID 从一个表保存到另一个表

c# - 创建和连接到 SQL Server 数据库的代码 : Whats wrong with it?