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开发,软件架构设计、分布式相关、项目管理、前端设计等等,实战派...
  • 相关阅读:
    docker使用阿里云Docker镜像库加速
    FastDFS文件系统(二) fastdfs和其他文件系统区别
    CentOS7—HAProxy安装与配置
    安装完CentOS 7 后必做的七件事
    让一个端口同时做两件事:http/https和ssh
    Hyper-v之利用差异磁盘快速创建多个虚拟机
    MySQL5.7安装与配置(YUM)
    CentOS7 配置阿里云yum源
    60款顶级大数据开源工具
    ubuntu设置分辨率
  • 原文地址:https://www.cnblogs.com/zqmingok/p/2199839.html
Copyright © 2011-2022 走看看