奇怪啊。gridview加了删除前确认,但是点了取消,他还是删除了啊。
<asp:TemplateField ShowHeader= "False ">
<ItemTemplate>
<asp:LinkButton ID= "LinkButton1 " runat= "server " CausesValidation= "False " CommandName= "Delete "
Text= "删除 " OnClientClick= "return confirm( '你确认要永久删除这条记录吗? '); "> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:ObjectDataSource ID= "ObjectDataSource1 " runat= "server " SelectMethod= "GetMenu_Class "
TypeName= "ClassLibrary.Jkdata.JkDataBasic " DeleteMethod= "DeleteMenuClass ">
<DeleteParameters>
<asp:Parameter Name= "ID " Type= "Int32 " />
</DeleteParameters>
</asp:ObjectDataSource>
奇怪啊。gridview加了删除前确认,但是点了对话框的“取消”,他还是删除了啊。
------解决方案--------------------protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton dBtn = (LinkButton)e.Row.Cells[9].Controls[0];
dBtn.Attributes.Add( "onclick ", "return confirm( '确认删除吗? '); ");
}
}
------解决方案--------------------OnClientClick= "return confirm( '你确认要永久删除这条记录吗? '); "
onclick
------解决方案-------------------- <asp:LinkButton ID= "LinkButton1 " runat= "server " CausesValidation= "False " CommandName= "Delete "
Text= "删除 " OnClientClick= "return confirm( '你确认要永久删除这条记录吗? '); "> </asp:LinkButton>
OnClientClick > > onclick
------解决方案--------------------学习一下
------解决方案--------------------return false就不会执行了
------解决方案--------------------OnClientClick= "if(!confirm( '你确认要永久删除这条记录吗? ')) return false; "
------解决方案--------------------