protected void Page_Load(object sender, EventArgs e)
{
// 客户端代码
Button1.Attributes["onclick"] = "javascript:return confirm('Are you sure?')";
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("You push the button!");
}
如果红色部分代码,则程序执行结果为:单击按钮后,选择确定按钮,则出现文字,否则不出现文字.但去掉经色部分代码后无论选择确定还是取消按钮,都会出现文字.