C# 如何请求确认删除检查表项目?

C# 如何请求确认删除检查表项目?,c#,javascript,asp.net,C#,Javascript,Asp.net,我有一些动态生成的清单项目。当用户删除它们时,应显示确认框。我该怎么做 protected void btndelete_Click(object sender, EventArgs e) { try { string conn = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString; S

我有一些动态生成的清单项目。当用户删除它们时,应显示确认框。我该怎么做

protected void btndelete_Click(object sender, EventArgs e)
        {
            try
            {
                string conn = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString;
                SqlConnection con = new SqlConnection(conn);
                con.Open();
            check:
                if (CheckBoxList1.SelectedItem != null)
                {
                    foreach (ListItem l in CheckBoxList1.Items)
                    {
                        if (l.Selected)
                        {
                            SqlCommand cmd = new SqlCommand("Drop Table " + l, con);
                            cmd.ExecuteNonQuery();
                            Label4.ForeColor = Color.Red;
                            Label4.Text = " PaperSet Deleted successfully";
                            CheckBoxList1.Items.Remove(l);
                            papersetlist.Items.Remove(l);
                            Psetlist.Items.Remove(l);
                            goto check;
                        }
                    }
                }
                con.Close();

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

这是删除按钮事件代码。

您只需编写类似的代码即可

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
 CommandName="Delete" Text="Delete" 
OnClientClick="return confirm('Are you certain you want to delete this item?');"> 
 </asp:LinkButton>


您是否查看了外观?您能发布一些到目前为止的示例代码吗?我不确定“当用户删除它们时”涉及到什么,但您可能希望显示一个实际的确认页面而不是JavaScript解决方案?用户的点击次数相同,但有一个额外的安全层。请对我的问题进行投票-2点阻止我提出更多问题…@rickevans-要完成任务,您只需在“删除”按钮上设置OnClientClick=“return confirm('您确定要删除此项目吗?');“就像我在“链接”按钮上所做的一样