nagaraju60 says:
Dear @dc4444,
Please refer below article, it might be help you
https://www.aspsnippets.com/Articles/Confirmation-Confirm-box-with-Yes-No-Buttons-Options-using-AJAX-Modal-Popup-Extender-in-ASPNet.aspx
My situation is differnet. I have a gridview and then a separate delete button below the grid.
When the delete button is clicked the code-behind first checks to ensure a gridview row was selected. If so, then that is when I want the modal window to appear to ask for delete confirmation.
1. How do I get the modal window only to appear if the gridview row was selected?
2. Then when the OK button on the modal window is selected pass that "OK" or "Cancel" back to the code-behind to actually determine whether to do the delete process or not?
Pseudo code:
protected void btnDelete_Click(object sender, EventArgs e)
{
try
{
// Check that a row was selected in the gridview.
if (GridView1.SelectedValue != null)
{
// Now is when I want to show the modal.
// Check if OK or Cancel.
// If OK selected, do the delete process.
if (OK selected)
{
// Instantiate the workshop BLL - business logic layer.
WorkshopBusiness WB = new WorkshopBusiness();
// Get the id of the Gridview row selected.
int Id = int.Parse(GridView1.SelectedValue.ToString());
// Call a method of the workshop business logic layer passing the id which then will call the data access to layer
// to process the delete.
WB.DeleteWorkshopById(Id, LoggedinUserName);
}
try
{
// Call the method herein to update the gridview.
GetWorkShops();
txtWorkShopTitle.Text = "";
txtWorkShopDate.Text = "";
txtWorkShopDuration.Text = "";
txtWorkShopTopics.Text = "";
// Clear the Trainer checkboxes.
ckbLTrainers.ClearSelection();
lblMessage.Text = "The workshop was deleted successfully !";
}
catch (Exception Ex)
{
lblMessage.Text = "Kindly contact the Admin at 00-000-000000. " + Ex.Message;
}
}
else
{
lblMessage.Text = "You must select a workshop.";
}
}
catch (Exception Ex)
{
lblMessage.Text = "Kindly contact the Admin at 00-000-000000. " + Ex.Message;
}
}