isdaviddong
1/29/2017 - 2:06 PM

isrock PageMethod Fx 範例樣板

isrock PageMethod Fx 範例樣板

    public partial class _default : System.Web.UI.Page
    {
        #region"PageMethod"
        [System.Web.Services.WebMethod(enableSession: true)]
        public static PageMethodDefaultResult<string> GetData()
        {
            return new PageMethodDefaultResult<string>()
            {
                isSuccess = true,
                Data = System.DateTime.Now.ToString()
            };
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
          
        }
    }
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/bootstrap.min.css" rel="stylesheet" />
    <link href="Content/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="Content/toastr.min.css" rel="stylesheet" />
    <script src="Scripts/jquery-1.9.1.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
    <script src="Scripts/toastr.min.js"></script>
    <script src="Scripts/vue.min.js"></script>
    <script src="Scripts/isRockFx.js"></script>
    <script>
        function Button1_click() {
            CallPageMethod('GetData', null,
                function (ret) { alert(ret.Data); })
        }

        $(document).ready(function () {
            $('#Button1').click(Button1_click);
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="row" style="margin: 12px">
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        範例 : 
                    </div>
                    <div class="panel-body">
                        <button class="btn btn-primary" id="Button1" type="button">GetData</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>