Pause data save processing when modal popup
How to pause data saving processing when showing modal popup? and when I click a button inside this modal popup, the data save execution will continue to be processed.
my Modal popup acts like a message box ...
here is my example code:
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.
Should I be using Threading ? Is Threading working on ASP.Net?
+3
source to share
1 answer
The save process is done on the server , but the modal dialog will be displayed on the client . You cannot make the server wait for the user's response in the browser. Instead, server processing should end and send the modified page to the browser. The browser will now present all the data along with a confirmation again. Since you are using ASP.NET WebForms, you are in luck as it automatically handles state for scenarios like this.
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);
}
0
source to share