http://www.cnblogs.com/blodfox777/articles/1261303.html
Button有兩個點擊事件:
onclick 觸發服務端事件,腳本為c#或VB.NET
OnClientClick 觸發客戶端事件,腳本一般為JavaScript,此屬性為ASP.NET 2.0新增,1.1之前需要使用添加attribute的方法來添加客戶端事件
在點擊按鈕時,先運行OnClientClick 中的腳本,如果返回值為true,則再運行button_onclick 中的代碼, 否則將不會執行該按鈕的后台代碼
demo:
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="return confirm('Are u sure?');" onclick="Button1_Click"/>
</div>
</form>
</body>
</html>

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("if you press OK, Button1_Click will be execute");
}
}