Asp.Net后台弹出确认提示窗Confirm

0
5

前端js代码:

function MyConfirm(message, guid) {
            if (confirm(message) == true) {
                document.getElementById("Hidden1").value = guid;
            }
            else {
                document.getElementById("Hidden1").value = "";
            }
            //form1.submit();
            form1.submit();
        }

后台C#代码:

 1     /// <summary>
 2     /// 用于标识Confirm是否继续当前操作
 3     /// </summary>
 4     public string ConfirmValue
 5     {
 6         get { return ViewState["ConfirmValue"] == null ? "" : ViewState["ConfirmValue"].ToString(); }
 7         set { ViewState["ConfirmValue"] = value; }
 8     }
 9 
10  protected void Page_Load(object sender, EventArgs e)
11     {
12         if (!string.IsNullOrEmpty(ConfirmValue))
13         {
14             btnSave_Click(null, null);//后台弹出确认对话框
15         }
16         if (IsPostBack)
17             {
18                 return;
19             }
20     }
21 
22 protected void btnSave_Click(object sender, EventArgs e)
23     {
24 
25 
26         if (string.IsNullOrEmpty(ConfirmValue))//提示
27                         {
28                             string strGuid = Guid.NewGuid().ToString();
29                             ConfirmValue = strGuid;
30                             ScriptManager.RegisterStartupScript(this, this.GetType(), "_ShowMessage", "MyConfirm('是否继续?','" + strGuid + "');", true);
31                             return;
32                         }
33                         if (!string.IsNullOrEmpty(ConfirmValue) && ConfirmValue != Hidden1.Value)//取消
34                         {
35                             ConfirmValue = "";
36                             //ShowMessage("提示", "您取消了当前操作");
37                             return;
38                         }
39                         else//如果点击确认,则需要把ConfirmValue初始化为空
40                         {
41                             ConfirmValue = "";
42                         }
43 }
44 
45 
46 
47 
48         

<

发布回复

请输入评论!
请输入你的名字