菜鸟提问:如何提示删除确认??
asp.net 2.0 C#
如果是LINKBUTTON按钮,那么我可以通过如下代码显示删除确认的提示:
<asp:LinkButton Text="删除" ID="delete" runat="server" CommandName="delete" OnCommand="delete_Command" OnClientClick="return confirm('您确定要删除该信息?')"></asp:LinkButton>
但是如果是GridWiew 中自带的删除按钮应该怎么实现??
<asp:ButtonColumn Text="删除" CommandName="Delete" ></asp:ButtonColumn>
[解决办法]
你可以给td 加一个class用js
function ConfirmDel() { return confirm("确定要将选中的项删除吗?") }
[解决办法]
你可以通过遍历gridrow的方式
foreach(GridRow row int girdview.Rows)
{
row.Cells[0].Controls[0].Attribute.Add("click","return confirm('确定要将选中的项删除吗?')");
}
switch (e.CommandName)
{
case "delete":
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script type='text/javascript'>jConfirm('是否删除该记录','提示',function(res){$('#hid').val(res)})</script>");
if (this.hid.Value =="true")
{
int id = (int)e.CommandArgument;
pBLL.DeleteInfo(id);
DataBindPage();
}
break;