页面如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form >
        function Button1_onclick() {
            PageMethods.GetServerTime(alt);
        }
        function alt(result) {
            alert(result);
        }
    </script>

    </form>
</body>
</html>

后台代码如下:

using System;
using System.Web;
using System.Web.UI;

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

    }

    [System.Web.Services.WebMethod]
    public static string GetServerTime()
    {
        return DateTime.Today.ToString();
    }
}

相关文章:

  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-26
  • 2022-02-02
  • 2021-06-27
  • 2022-12-23
  • 2022-02-01
  • 2021-11-29
相关资源
相似解决方案