zoukankan      html  css  js  c++  java
  • ajaxpro.2.dll 简单应用

    1.添加 ajaxpro.2.dll 引用

    2.web.config
    <system.web>

        
    <httpHandlers>
          
    <add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
        
    </httpHandlers>
    </system.web>

    3.服务器端代码
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class Ajax : System.Web.UI.Page
    {
        
    protected void Page_Load(object sender, EventArgs e)
        
    {
            AjaxPro.Utility.RegisterTypeForAjax(
    typeof(Ajax));
        }


        [AjaxPro.AjaxMethod]
        
    public string GetServerTimeString()
        
    {
            System.Threading.Thread.Sleep(
    2000);
            
    return DateTime.Now.ToString();
        }

    }

    4.客户端代码

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

    <!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>ajaxpro.2.dll 简单应用</title>
        
    <script language="javascript" type="text/javascript">
           
    function ajax_callback(response)
           
    {             
                 document.getElementById(
    "div1").innerHTML = response.value;
           }

           
    function getServerTime()
           
    {
              document.getElementById(
    "div1").innerHTML = "请稍后,正在获取服务器时间..";
              Ajax.GetServerTimeString(ajax_callback);
              
           }

           
        
    </script>
    </head>
    <body>
        
    <form id="form1" runat="server">
        
    <div>
        
        
    <div id="div1">点击按钮获取服务器端时间</div>

        
    <input type="button" value=" click " onclick="javascript:getServerTime();" />
        
        
    </div>
        
    </form>
    </body>
    </html>
  • 相关阅读:
    保护ASP.NET 应用免受 CSRF 攻击
    在html页头设置不缓存
    ASP.NET MVC – 关于Action返回结果类型的事儿(上)
    UC浏览器 分享到朋友圈和微信好友
    利用java Base64 实现加密、解密
    Java图片工具类,完成图片的截取和任意缩放
    iscroll动态加载数据完美解决方案
    ASP.NET三层架构的分析
    如何用浏览器调试js代码
    练习使用jquery.并将验证强度的功能加到注册页面中
  • 原文地址:https://www.cnblogs.com/yiki/p/795851.html
Copyright © 2011-2022 走看看