RT
btnDeleteExam.Attributes.Add("onclick", "return confirm('您确定要删除卷纸: " +ddlResult.SelectedValue+ " 嘛?');");
以前是像上面那么写的 但是有局限性
-------------------------------------------
现在小弟想在 GRIDVIEW 的 删除按钮上 点击删除的时候 先弹出对话框 问是否删除 点是再删除
代码如下 protected void grdSingle_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int index = Int32.Parse(e.CommandArgument.ToString());
int id = Int32.Parse(grdSingle.Rows[index].Cells[1].Text);
Response.Redirect("UpdateSingle.aspx?id=" + id);
}
else if (e.CommandName == "Delete")//想在这加个弹出对话框!
{
int index = Int32.Parse(e.CommandArgument.ToString());
int id = Int32.Parse(grdSingle.Rows[index].Cells[1].Text);
try
{
db.DeleteUser(id);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
bindSingle();
DeleteDadPaper();
}
}在线等...
btnDeleteExam.Attributes.Add("onclick", "return confirm('您确定要删除卷纸: " +ddlResult.SelectedValue+ " 嘛?');");
以前是像上面那么写的 但是有局限性
-------------------------------------------
现在小弟想在 GRIDVIEW 的 删除按钮上 点击删除的时候 先弹出对话框 问是否删除 点是再删除
代码如下 protected void grdSingle_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int index = Int32.Parse(e.CommandArgument.ToString());
int id = Int32.Parse(grdSingle.Rows[index].Cells[1].Text);
Response.Redirect("UpdateSingle.aspx?id=" + id);
}
else if (e.CommandName == "Delete")//想在这加个弹出对话框!
{
int index = Int32.Parse(e.CommandArgument.ToString());
int id = Int32.Parse(grdSingle.Rows[index].Cells[1].Text);
try
{
db.DeleteUser(id);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
bindSingle();
DeleteDadPaper();
}
}在线等...
将删除按钮改模板列,
进入编辑模板,点中删除按钮,在OnClientClick的属性中输入return confirm('你确要删除吗?')
就可以了!!
对应的代码:
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick="return confirm('你确要删除吗?')" Text="删除"></asp:LinkButton>
</ItemTemplate>2.在GridView的RowDataBind事件中设置!!
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandArgument='<%# Eval("SD_ClassId") %>' CommandName="Delete"
Text="删除" OnClientClick="return confirm('您是否确定要删除该栏目吗?')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
OnClientClick="return confirm('你确要删除吗?')" Text="删除"> </asp:LinkButton>
up