事件执行到一半时,要和页面互动,除了用ajax还有什么办法。写了一个方法
#########前台的aspx#########
<%@ 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" type="text/javascript">
        function posted() {
            if (confirm("后台是否继续操作?")) {
                document.getElementById('HiddenField1').value = "true";
                document.getElementById('Button1').click()
            }
            else {
                document.getElementById('HiddenField1').value = "false";
                document.getElementById('Button1').click()
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </div>
     <asp:HiddenField ID="HiddenField1" runat="server" Value="OK" />
    </form>
</body>
</html>#########后台的 CS #########
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)
    {}
    protected void Button1_Click(object sender, EventArgs e)
    {
         string mags = "";
        //第一次执行
        if (this.HiddenField1.Value == "OK")
        {
            this.Label1.Text = "有用的数据!";//保存后续需要的数据到缓存
            //(前台)弹出对话框!
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "posted()", true);
        }
        //选择确定
        else if (this.HiddenField1.Value == "true")
        {
            mags = "你选择了继续执行!" + this.Label1.Text;//需要得到第一次执行的数据
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "alert('" + mags + "')", true);
            this.HiddenField1.Value = "OK";
            //清空缓存
            this.Label1.Text = "执行了清空";
        }
        //选择取消
        else if (this.HiddenField1.Value == "false")
        {
            mags = "你不继续执行了!";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "alert('" + mags + "')", true);
            this.HiddenField1.Value = "OK";
            //清空缓存
            this.Label1.Text = "清空";
        }
    }   
}