当前位置: 移动技术网 > IT编程>开发语言>.net > Asp.Net后台弹出确认提示窗Confirm

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

2019年08月25日  | 移动技术网IT编程  | 我要评论

驯服大丈夫,魏俫,男士脸部皮肤保养

前端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         

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网