2010年4月29日 星期四

GridView 刪除按鈕添加確認訊息範例

1. GridView加入編輯/刪除按鈕於最後
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />

2. 於 rowdatabound 事件加入下面程式
if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == 0)
{
LinkButton lb = e.Row.Cells[e.Row.Cells.Count - 1].Controls[2] as LinkButton;
lb.OnClientClick = "if (!confirm('確定刪除?')) return false;";
}

沒有留言:

自訂權限驗證機制

// 使用 filter [Route("api/[controller]")] [ApiController] [Authorize] [TypeFilter(typeof(CustomAsyncAuthorizationFilter))] public c...