zoukankan      html  css  js  c++  java
  • 使用JQUERY UI中的dialog对话框提示,如果点击确认,执行服务端代码的基本代码


    <!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 src="../css/jquery-1.3.2.js" type="text/javascript"></script>

        <link type="text/css" href="../css/themes/base/ui.all.css" rel="stylesheet" />

        <script type="text/javascript" src="../css/ui/ui.core.js"></script>

        <script type="text/javascript" src="../css/ui/ui.resizable.js"></script>

        <script type="text/javascript" src="../css/ui/ui.draggable.js"></script>

        <script type="text/javascript" src="../css/ui/ui.dialog.js"></script>

        <script type="text/javascript" src="../css/ui/effects.core.js"></script>

        <script type="text/javascript" src="../css/ui/effects.highlight.js"></script>

        <script type="text/javascript" src="../css/external/bgiframe/jquery.bgiframe.js"></script>

        <link type="text/css" href="../css/demos.css" rel="stylesheet" />
            <script type="text/javascript">
                $(function() {
                    $("#dialog").dialog({
                        bgiframe: true,
                        autoOpen: false,
                        height: 300,
                        modal: true,
                        buttons: {
                            '是': function() {

                                $(this).dialog("close");
                                //alert($("#<%= hdnBtnPostback.ClientID %>").val());
                                eval($("#<%= hdnBtnPostback.ClientID %>").val());
                            },
                            "否": function() {
                                $(this).dialog('close');
                            }
                        }
                    });

                });
                function showjQueryDialog() {
                    $('#dialog').dialog('open');
                }
     </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <div id="dialog" title="Create new user">
            你是否需要发送一个短信给审批人:
        </div>
        </div>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"
            onclientclick="showjQueryDialog();return false;" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:HiddenField ID="hdnBtnPostback" runat="server" />
        </form>
    </body>
    </html>

    后台

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class test_DialogConfirm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hdnBtnPostback.Value = Page.ClientScript.GetPostBackEventReference(Button1, string.Empty);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "保存成功!";
        }
    }

    另客户端设用服务端click事件的方法


    <!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 src="../css/jquery-1.3.2.js" type="text/javascript"></script>

        <script language="javascript" type="text/javascript">
            $().ready(function() {
                $("#Button2").click(function() {
                    $("#Button1").click();
                });
            })
        </script>

    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="服务器端控件" OnClick="Button1_Click" />
            <input id="Button2" type="button" value="客户端控件"><br />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            <hr />
            <a href="#" onclick="<%= PostBack()%>">test</a>
        </div>
        </form>
    </body>
    </html>

    后台

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class test_ClientPostback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Label1.Text = "test";
            if (Request["__EVENTARGUMENT"] == "haha")
            {
                Response.Write("这个是链接的PostBack");
            }
            else
            {
                Response.Write("这个不是链接的PostBack");
            }
        }
        protected string PostBack()
        {
            return this.Page.GetPostBackEventReference(Button1, "haha");
        }
    }

  • 相关阅读:
    非诚勿扰骆琦攻略
    IT服务者的困惑与解决之道
    某某银行IT运维管理的三点和四化
    提升CIO地位及IT价值体现,IT治理理念在中国势在必行
    振兴民族软件,险恶的江湖该如何仗剑走天涯
    某连锁饭店IT服务台、自助服务建设
    证券行业ITIL初探助力券商成就IT管理之路
    分享屡见成效的另类方法论保障ITIL软件及ITSM方案落地实施
    城市商业银行IT科技工作管理之痛
    【转】陈天晴:信息化发展要注意规划调整 重视IT治理
  • 原文地址:https://www.cnblogs.com/hhq80/p/1615821.html
Copyright © 2011-2022 走看看