惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
Vercel News
Vercel News
Last Week in AI
Last Week in AI
H
Help Net Security
The Cloudflare Blog
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
I
InfoQ
U
Unit 42
美团技术团队
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
宝玉的分享
宝玉的分享
量子位
博客园_首页

博客园 - 博闻李

SQL Server数据库所有表索引性能分析 SQL Server数据库所有表重建索引 查询数据库字段所在的位置 查询时锁的使用[转] DBCC DBREINDEX重建索引提高SQL Server性能[引] Javascript键盘输入相关 - 博闻李 - 博客园 VS2008 Web Application和Web Site的区别[转] IIS Temporary ASP.NET Files拒绝访问解决方案 WebDAV是什么?[引] ASP.NET C# 访问Oracle数据库示例 VSTS 2008的TFS安装实战[转] Oracle PL/SQL常用函数列表[转载] Oracle初学笔记 SQL Server 索引结构及其使用(一)[转] SQL数据库设计经验[转] 一套外企的数据库设计面试题[转] UML在关系型数据库设计中的应用[转] 数据库设计范式深入浅出[转] showModalDialog和showModelessDialog使用[转]
ASP.NET AJAX中PageMethods方法调用示例 - 博闻李 - 博客园
博闻李 · 2009-06-20 · via 博客园 - 博闻李

页面如下:

<%@ 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 id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
    <script language="javascript" type="text/javascript">
        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();
    }
}