在Datagrid for Command Field中删除操作之前显示确认消息

时间:2013-04-17 07:00:57

标签: jquery asp.net

我有一个带有CommandField的数据网格来删除一行。如何在删除行之前要求用户确认删除。

<asp:CommandField HeaderText="Изтрий" ShowDeleteButton="True" DeleteText="Изтрий" />

4 个答案:

答案 0 :(得分:2)

<asp:ImageButton runat="server" ID="btnDelete" ImageUrl="/Images/icons/user_delete.png" 
 ToolTip="Delete Product" CommandName="Delete"   OnClientClick="return confirm('Do you want to delete this product size ?')" />

答案 1 :(得分:0)

这个例子可以帮助你。如果你使用asp控件使用OnClientClick="logout()"无论你的功能是什么

<script>
function logout()
{
if (confirm('Are you sure you want to logout?'))
location.href = "http://www.tackleprices.com/merchant/logout.php";
}
</script>

答案 2 :(得分:0)

使用Jquery

为数据网格中的删除按钮添加确认消息

你可以为你的删除按钮设置一个类。我的类是“btndelete”

 <asp:ButtonColumn ItemStyle-CssClass="btndelete"  ButtonType="PushButton" CommandName="Delete" Text="delete"></asp:ButtonColumn>

然后编写Jquery代码

  $('.btndelete').live('click', function () {
            return confirm("Are you sure you want to delete this record?");
        });

这项工作对我来说!

答案 3 :(得分:0)

这是一篇代码项目文章,它准确描述了您要归档的内容:

http://www.codeproject.com/Articles/32756/ASP-NET-GridView-delete-confirmation-using-asp-Com

HTH

相关问题