zoukankan      html  css  js  c++  java
  • AjaxPro.AjaxNamespace

     

    首先下载ajaxpro.dll,你可以从http://www.ajaxpro.info/获得。最新版本是7.7.31.1,下载解压后的文件夹中有个AjaxPro.dll,就是它了。使用VS2008新建web项目,并添加对AjaxPro.dll的引用,然后在Web配置文件中添加:

            <httpHandlers>
                
    <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
            
    </httpHandlers>
        这个配置项表明所有的ajaxpro/*.ashx请求(即从客户发送的Ajax请求)都交给AjaxPro.AjaxHandlerFactory处理,而不是由默认的System.Web.UI.PageHandlerFactory来处理。 
        我这里是新建的测试页面test6

     1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test6.aspx.cs" Inherits="test6" %>
     2
     3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     4<html xmlns="http://www.w3.org/1999/xhtml">
     5<head id="Head1" runat="server">
     6    <title></title>
     7
     8    <script type="text/javascript">
     9        function getID(id) {
    10            return document.getElementById(id);
    11        }

    12
    13        //无刷新返回当前时间
    14        function Time() {
    15            getID("str1").innerHTML = Main.getTime().value;
    16        }

    17    </script>
    18
    19</head>
    20<body>
    21    <form id="form1" runat="server">
    22    <div>
    23        <input id="Button1" type="button" value="无刷新返回当前时间" onclick="Time()" />
    24        <span id="str1" />
    25    </div>
    26    </form>
    27</body>
    28</html>
    29

     1using System;
     2using System.Collections;
     3using System.Configuration;
     4using System.Data;
     5using System.Web;
     6using System.Web.Security;
     7using System.Web.UI;
     8using System.Web.UI.HtmlControls;
     9using System.Web.UI.WebControls;
    10using System.Web.UI.WebControls.WebParts;
    11
    12[AjaxPro.AjaxNamespace("Main")]
    13public partial class test6 : System.Web.UI.Page
    14{
    15    protected void Page_Load(object sender, EventArgs e)
    16    {
    17        //注册本页为AJAX
    18        AjaxPro.Utility.RegisterTypeForAjax(typeof(test6));
    19    }

    20
    21    //无刷新返回当前时间
    22    [AjaxPro.AjaxMethod]
    23    public string getTime()
    24    {
    25        string Time = "<font color='green'>" + DateTime.Now.ToString() + "</font>";
    26        return Time;
    27    }

    28}

    29
    keim,毕业于安徽科技学院理学院,2003年开始对Web开发有浓厚的兴趣,并专注于C#/java Web开发,软件架构设计、分布式相关、项目管理、前端设计等等,实战派...
  • 相关阅读:
    (44)FreeRTOS学习之一
    (43)软件架构设计思想总结
    (42)嵌入式项目中常用到的C语言技能总结
    (41)freeRTOS之任务管理
    (40)每个新手程序员都会犯的5个错误
    (39)23种设计模式研究之十【状态模式】
    (38)23种设计模式研究之九【迭代器模式和组合模式】
    (37)23种设计模式研究之八【模板方法模式】
    (36)23种设计模式研究之七【适配器模式和外观模式】
    (35)23种设计模式研究之六【命令模式】
  • 原文地址:https://www.cnblogs.com/zqmingok/p/2199839.html
Copyright © 2011-2022 走看看