Ajax.Net Professional——A quick guide how to start(AjaxPro开始向导)
2012-05-27 17:52
531 查看
Because I could not write a documentation I will show you here how to start:
Download the latest Ajax.NET Professional files from
www.schwarz-interactive.de
Add a reference to the AjaxPro.2.dll (for the .NET 1.1 Framework use AjaxPro.dll)
Add following lines to your web.config:
因为我不会写文档,我将以如下方式告诉你如何开始:
(1)下载最新版的AjaxPro文件
(2)添加AjaxPro的引用。(.NET1.1使用AjaxPro.dll,其他版本的.NET使用AjaxPro.2.dll)
在web.config文件中添加以下几行:
ashx百度百科:http://baike.baidu.com/view/3799515.htm
PS:CSDN的编辑器有点问题,源代码里边并没有<strong>编辑,该标记是CSDN的代码格式化编辑,在编辑页面中没有该标记,但在发布后的页面中却多了该标记,要注意把它删掉。
Now, you have to mark your .NET methods with an AjaxMethod attribute:
然后,你需要使用AjaxMethod属性来标注你的.NET方法。
To use the .NET method on the client-side JavaScript you have to register the methods, this will be done to register a complete class to Ajax.NET:
在客户端使用JS来调用.NET方法,你需要注册这些方法(被JS调用的.NET方法)。通过注册一个完整的类名来实现。
ps:使用AjaxPro.Utility.RegisterTypeForAjax()方法来注册一个类为Ajax类。参数为类名,可通过使用typeof操作符获取。
If you start the web page two JavaScript includes are rendered to the HTML source.
如果你的web页面包含以下两段JS代码,在HTML源代码中将会显示为下边代码所示:
To call a .NET method form the client-side JavaScript code you can use following syntax:
在客户端通过JS代码来调用一个.NET(服务器端)方法,使用下边所示的语法:
PS:使用完全的限定名,命名空间.类名.方法名:MyDemo._Default.GetServerTime在客户端,使用JS代码,方法getServerTime调用服务器端的GetServerTime方法来获取时间,返回值可以直接赋值给客户端JS的一个变量或者通过回调函数,将返回值发送给回调函数,作为其参数,然后在回调函数中做处理。
Download the latest Ajax.NET Professional files from
www.schwarz-interactive.de
Add a reference to the AjaxPro.2.dll (for the .NET 1.1 Framework use AjaxPro.dll)
Add following lines to your web.config:
因为我不会写文档,我将以如下方式告诉你如何开始:
(1)下载最新版的AjaxPro文件
(2)添加AjaxPro的引用。(.NET1.1使用AjaxPro.dll,其他版本的.NET使用AjaxPro.2.dll)
在web.config文件中添加以下几行:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/> </httpHandlers> [...] </system.web> </configuration>
ashx百度百科:http://baike.baidu.com/view/3799515.htm
PS:CSDN的编辑器有点问题,源代码里边并没有<strong>编辑,该标记是CSDN的代码格式化编辑,在编辑页面中没有该标记,但在发布后的页面中却多了该标记,要注意把它删掉。
Now, you have to mark your .NET methods with an AjaxMethod attribute:
然后,你需要使用AjaxMethod属性来标注你的.NET方法。
[AjaxPro.AjaxMethod] public DateTime GetServerTime() { return DateTime.Now; }
To use the .NET method on the client-side JavaScript you have to register the methods, this will be done to register a complete class to Ajax.NET:
在客户端使用JS来调用.NET方法,你需要注册这些方法(被JS调用的.NET方法)。通过注册一个完整的类名来实现。
namespace MyDemo
{
public class _Default
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
}
[AjaxPro.AjaxMethod] public DateTime GetServerTime() { return DateTime.Now; }
}
}
ps:使用AjaxPro.Utility.RegisterTypeForAjax()方法来注册一个类为Ajax类。参数为类名,可通过使用typeof操作符获取。
If you start the web page two JavaScript includes are rendered to the HTML source.
如果你的web页面包含以下两段JS代码,在HTML源代码中将会显示为下边代码所示:
To call a .NET method form the client-side JavaScript code you can use following syntax:
在客户端通过JS代码来调用一个.NET(服务器端)方法,使用下边所示的语法:
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); }
PS:使用完全的限定名,命名空间.类名.方法名:MyDemo._Default.GetServerTime在客户端,使用JS代码,方法getServerTime调用服务器端的GetServerTime方法来获取时间,返回值可以直接赋值给客户端JS的一个变量或者通过回调函数,将返回值发送给回调函数,作为其参数,然后在回调函数中做处理。
相关文章推荐
- An example on how to use jQuery and Ajax.NET Professional together
- T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers
- zhuanzai: AJAX: How to create a "Processing" modal window using UpdateProgress and ModalPopup ASP.net AJAX controls
- The QuickStart Guide to Learning BizTalk Server 2004
- Ajax.NET Professional (AjaxPro)
- OllyDbg完全教程 如何开始调试[How to start debugging session] CPU 窗口[CPU window]
- The QuickStart Guide to Learning BizTalk Server 2004
- [ASP.NET AJAX]How to register javascript functions after UpdatePanel updated
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project
- Welcome to the Ajax.NET Professional Starter Kit
- How To Start A Blog [如何开始博客之旅]
- Unreal教学(8)——蓝图学习快速开始(Blueprints Quick Start Guide)
- Quartz.NET - Quartz.NET Quick Start Guide
- T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers
- A Quick Start Guide to iBATIS DataMapper
- Quartz.NET - Quartz.NET Quick Start Guide
- Running Ajax.NET Professional (AjaxPro) under ASP .NET MVC(转)
- How to Start a Conversation?——如何开始交谈?
- How to fix intellisense issues after upgrading to ASP.NET Ajax 1.0 RC
- How to fix intellisense issues after upgrading to ASP.NET Ajax 1.0 RC