首页新闻找找看学习计划

asp.net 后台提交弹出窗体

0
悬赏园豆:10 [已解决问题] 解决于 2013-08-13 13:23

asp.net 后台提交弹出窗体怎样做到点击确定就提交,点击取消就不提交

blog_yuan的主页 blog_yuan | 初学一级 | 园豆:6
提问于:2013-08-12 14:08
< >
分享
最佳答案
0
 DialogResult dr = MessageBox.Show("Aer you sure?", "show", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
)//判断是否是点击的确定(OK)
}
收获园豆:10
W宁宁 | 小虾三级 |园豆:522 | 2013-08-12 14:50

你是java,我认得

blog_yuan | 园豆:6 (初学一级) | 2013-08-12 16:31

@blog_yuan: 不是啊

W宁宁 | 园豆:522 (小虾三级) | 2013-08-12 16:33

  protected void LinkButton1_Click(object sender, EventArgs e)
        {
            if (!this.IsClientScriptBlockRegistered("clientScript"))
            {
                // Form the script that is to be registered at client side.
                String scriptString = "<script lanage='javascript'>if (confirm('Confirm me?')) __doPostBack('LinkButton1','')</script>";
                this.RegisterClientScriptBlock("clientScript", scriptString);

            }

            //Page.ClientScript.RegisterStartupScript(this.GetType(), "Cscript", "<script> (function(){ if(!confirm('确认要切换为实时交易吗?')){ return false; } })() </script>");
            show();
        } 这样的可以使用,谢谢你的解答

blog_yuan | 园豆:6 (初学一级) | 2013-08-13 13:21
其他回答(6)
0

点确定就return true;点取消就return false;

Meen | 园豆:321 (菜鸟二级) | 2013-08-12 14:20

要点击取消之后,不再执行后面的C# 代码, Page.ClientScript.RegisterStartupScript(this.GetType(), "Cscript", "<script> confirm('确认要切换为实时交易吗?')  </script>"); 执行之后点击取消不再执行show() 方法。

show();

支持(0) 反对(0) blog_yuan | 园豆:6 (初学一级) | 2013-08-12 18:06
1
<%@ 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 type="text/javascript">
        function go() {
            if (confirm("你好!")) {
                return true;
            } else {
            return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server"  onsubmit="return go()">
    <div>
        hello!<asp:Button ID="Button1" runat="server" Text="Button" 
            onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>
clcvc | 园豆:62 (初学一级) | 2013-08-12 14:24
0
添加Confirm确认弹出窗体:
在page_load里面添加代码(以button为例子)
Button.Attributes.Add("onclick","return confirm(''确定?'')")
zhangzl | 园豆:461 (菜鸟二级) | 2013-08-12 15:25

  protected void LinkButton1_Click(object sender, EventArgs e)
        {
            if (!this.IsClientScriptBlockRegistered("clientScript"))
            {
                // Form the script that is to be registered at client side.
                String scriptString = "<script lanage='javascript'>if (confirm('Confirm me?')) __doPostBack('LinkButton1','')</script>";
                this.RegisterClientScriptBlock("clientScript", scriptString);

            }

            //Page.ClientScript.RegisterStartupScript(this.GetType(), "Cscript", "<script> (function(){ if(!confirm('确认要切换为实时交易吗?')){ return false; } })() </script>");
            show();
        } 这样的可以使用,谢谢你的解答

支持(0) 反对(0) blog_yuan | 园豆:6 (初学一级) | 2013-08-13 13:21
0

在Button的OnClientClient事件中直接写 JavaScript:return confirm('确定提交吗?')如下

<asp:Button runat="server" id="bunID" OnClientClient='JavaScript:return confirm('确定提交吗?')' />

小兵仔 | 园豆:1240 (小虾三级) | 2013-08-12 17:14
0

对于Asp.net的按钮来说,直接设置OnClientClick="return confirm('你确定要操作吗?')",类似这样的即可。

幻天芒 | 园豆:36522 (高人七级) | 2013-08-12 18:41
0

confirm提示框的应用就可以了

panjk | 园豆:712 (小虾三级) | 2013-08-13 08:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册