62,243
社区成员




<%@ 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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
using System;
using System.Web.UI;
public partial class _Default : System.Web.UI.Page, IPostBackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm",
"if(confirm('你确定1+1=2吗?'))" + this.ClientScript.GetPostBackEventReference(this, "确定") + "; else " +
this.ClientScript.GetPostBackEventReference(this, "不确定"), true);
}
public void RaisePostBackEvent(string eventArgument)
{
string res;
switch (eventArgument)
{
case "确定":
res = "太有才了!"; //处理各种后台任务
break;
case "不确定":
res = "是块当实习生的料。"; //处理各种后台任务
break;
default:
throw new NotSupportedException();
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('" + res + "');", true);
}
}
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('确认添加?'))alert('点击了确定');else alert('点击了取消')</script>");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('确认添加?'))alert('点击了确定');else alert('点击了取消')</script>");
Response.write("<script>confirm('自定义提示信息)</script>");
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>if(confirm('确认添加?'))alert('点击了确定');else alert('点击了取消')</script>");