Ajaxpro makes the ajaxpro of. NET Simple

Source: Internet
Author: User
Tags datetime net return client

this time to use Ajax, but completely on their own to write too annoying, unwilling to do some trouble.

happened to see Ajaxpro, try it, feel very simple, very practical, compatibility is also very good.

Ajaxpro's official website is http://ajaxpro.info, you can download to the latest Ajaxpro components.

in the downloaded file, there are VS2005 templates, installed VS2005 template, can be directly established in VS2005 Ajaxprowebsite, in the establishment of the Ajaxprowebsite, there is a default demo, in fact, through it, will be able to fully understand the use of Ajaxpro.

If you're using a. NET2.0, and do not VS2005 words. All you need to do is put Ajaxpro.2.dll in the application's Bin folder, and only the following steps are required:

1. Modify Web.config

add under the system.web node

The following are the referenced contents:

<system.web>
<add verb= "Post,get" path= "Ajaxpro/*.ashx" type= "ajaxpro.ajaxhandlerfactory, ajaxpro.2"/>

2, will your. net method to add the Ajaxmethod property

The following are the referenced contents:

[Ajaxpro.ajaxmethod]
Public DateTime GetServerTime ()
{
return datetime.now;
}

3, in the. Net method to register JavaScript to the client, used for JavaScript
The following are the referenced contents:

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;
}
}
}

4, the client uses JavaScript to invoke the server side method, the syntax is also very simple
The following are the referenced contents:

function GetServerTime ()
{
Mydemo._default.getservertime (Getservertime_callback); Asynchronous call
}

This method is called after the method has been executed
And the result has been sent to the client.

function Getservertime_callback (res)
{
alert (Res.value);
}

In this way, a few simple steps, it has been completed. The client uses JavaScript to asynchronously invoke the server-side C # method and can get the server-side return value, which is passed to Javascript,javascript to handle the returned value, an example officially given. The server side returns a DateTime, but we can also return a complex data type, like a DataTable, which, in short, Ajaxpro Ajax very simply.

However, there is one point I do not fully understand, that is, ajaxpro.onloading, it can be when the server does not send back the value of the time to show the customer loading a class of things; I use the process, sometimes there will be ajaxpro undefined situation. On this point, but also on Google groups to see the relevant answers, but I still do not fully understand.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.