zoukankan      html  css  js  c++  java
  • AjaxPro让.NET的AjaxPro变得简单

    跟踪前台返回结果如下:
    v   =   { "value ":new   Ajax.Web.DataSet([new   Ajax.Web.DataTable([[ "id ", "System.String "],[ "name ", "System.String "],[ "dizhou_id ", "System.String "],[ "sheng_id ", "System.String "]],[[ "01 ", "市辖区 ", "01 ", "65 "],[ "02 ", "天山区 ", "01 ", "65 "],[ "03 ", "沙依巴克区 ", "01 ", "65 "],[ "04 ", "新市区 ", "01 ", "65 "],[ "05 ", "水磨沟区 ", "01 ", "65 "],[ "06 ", "头屯河区 ", "01 ", "65 "],[ "07 ", "达坂城区 ", "01 ", "65 "],[ "08 ", "东山区 ", "01 ", "65 "],[ "09 ", "经济技术开发区 ", "01 ", "65 "],[ "10 ", "高新技术产业开发区 ", "01 ", "65 "],[ "21 ", "乌鲁木齐县 ", "01 ", "65 "]])])}; 
     AjaxPro2 返回DataSet 时出现" 缺少对象"错误 的问题解决办法:
    这个它的一个bug!
    可以通过修改源代码解决这个问题。
    具体方法:
    1.下载源代码
    2.在   "AjaxPro\JSON\Converters\"下找到"DataTableConverter.cs"文件。
    3.修改第71行,
    if   (!AjaxPro.Utility.Settings.OldStyle.Contains("renderJsonCompliant"))
    把"!"去掉然后重新编译就好了。

    --------------------------------------------------------------------------
    AjaxPro之官网是http://ajaxpro.info,你可以下载到最新之AjaxPro组件。如果你想下载,可以点里这里

    在下载之之文件中,有VS2005之模板,安装了VS2005模板,就可以在VS2005中直接建立AjaxProWebSite了,在建立之AjaxProWebSite中,有一个默认之Demo,其实通过它,就能够完全了解AjaxPro之用法。

    如果你用之是.NET2.0,且不用VS2005之话。你只需要把AjaxPro.2.dll放入应用程序之bin文件夹中,而且也只需要如下几步:

    1、修改web.config

    在system.web节点下添加

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

    2、将你之.NET方法添加AjaxMethod属性

    [AjaxPro.AjaxMethod]
    public DateTime GetServerTime()
    {
       return DateTime.Now;
    }

    3、在.NET方法中向客户端注册javascript,用以javascript使用

    namespace MyDemo
    {
       public class _Default
       {
         protected void Page_Load(object sender, EventArgs e)
         {
           AjaxPro.Utility.RegisterTypeForAjax(this.GetType());
         }

         [AjaxPro.AjaxMethod]
         public DateTime GetServerTime()
         {
           return DateTime.Now;
         }
       }
    }

    4、在客户端用javascript调用服务器端之方法,语法也很简单

    function getServerTime()
    {
       MyDemo._Default.GetServerTime(getServerTime_callback);   // asynchronous call
    }

    // This method will be called after the method has been executed
    // and the result has been sent to the client.

    function getServerTime_callback(res)
    {
       alert(res.value);
    }

    就这样,简单之几步,就已经完成了。在客户端用javascript异步调用服务器端之C#方法,并可以得到服务器端之返回值,这个值会传到javascript,javascript可以处理这个返回之值,这个示例是官方给出之示例,服务器端返回之是一个DateTime,不过,我们也可以返回复杂之数据类型,像DataTable之类,总之,AjaxPro把Ajax搞得很简单。

  • 相关阅读:
    MTGA天梯利用Ummored Ego进行针对核心卡列表
    三日狂欢_THDN_简介
    Unity_Dungeonize 随机生成迷宫
    Match3 Module For Game(THDN)
    UNITY->(width*height)style Inventory
    Mysql基本配置以及常见问题
    C++||变量
    c++||OOP
    c++||template
    实用的js函数
  • 原文地址:https://www.cnblogs.com/gghxh/p/1009085.html
Copyright © 2011-2022 走看看