Вы можете использовать эфирный код jQuery для добавления этого предупреждающего сообщения.
С помощью кода вы можете добавить дополнительный вызов javascript как
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// loop all data rows
foreach (DataControlFieldCell cell in e.Row.Cells)
{
// check all cells in one row
foreach (Control control in cell.Controls)
{
// I go to get the button if exist
Button button = control as Button;
if (button != null && button.CommandName == "delete")
// Add delete confirmation
button.OnClientClick = "return confirm("Delete this record? This action cannot be undone...");";
}
}
}
}
Прямое использование jQuery и javascript вы можетедобавить этот JavaScript.
<script type="text/javascript">
$(document).ready(function() {
// make sure to select the correct buttons, here I say that value=Delete
var oButtons = $('#<%= YourGridID.ClientID %> :button[value=Delete]');
oButtons.each(function () {
// capture here any other click event.
var onclick = $(this).attr('onclick');
$(this).attr('onclick', null).click(function () {
var doPostBack = confirm("Delete this record? This action cannot be undone...");
if (doPostBack)
return onclick();
else
return false
});
});
});
</script>