<%@ Page
Language
="C#"
AutoEventWireup
="true"
CodeFile
="Default.aspx.cs"
Inherits
="_Default"
%
>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
></
title
>
<
script
language
="javascript"
>
function
DeleteData() {
if
(confirm(
'
你确认要删除所选信息?
'
)) {
if
(confirm(
'
删除后无法恢复,请再次确认?
'
)) {
alert(
'
已删除
'
)
}
}
}
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:LinkButton
ID
="LinkButton1"
runat
="server"
onclick
="LinkButton1_Click"
>
CS后台方式
</
asp:LinkButton
>
<
input
type
="button"
name
="xx"
onclick
="DeleteData()"
value
="删除"
/>
<
a
href
="###"
onclick
="DeleteData()"
>
删除
</
a
>
</
div
>
</
form
>
</
body
>
</
html
>
-
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
_Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
Page.IsPostBack)
{
LinkButton1.Attributes.Add(
"
onclick
"
,
"
javascript:if(confirm(\"你确认要删除所选信息?\")){if(confirm(\"删除后无法恢复,请再次确认?\")){return true;}}
"
);
}
}
protected
void
LinkButton1_Click(
object
sender, EventArgs e)
{
this
.RegisterStartupScript(
"
msg
"
,
"
<script language=\"javascript\">alert('已删除')</script>
"
);
}
}