Ajax asp.net Beginner's practice

Source: Internet
Author: User
Tags add net reference return client
Ajax|asp.net Ajax cannot be said to be a good technique. Just had a ajax.net, to try.

Download a compressed package from the http://ajax.net/, unlock a txt quick usage guide and a doc Ajax. NET wrapper usage guide and a DLL.

Well, look at the txt first. Learn about the general steps of Ajax development:

A, project to establish a reference, the Ajax.dll reference in.

Ii. Modify the Web.config document and join




<add verb= "Post,get" path= "Ajax/*.ashx" type= "Ajax.pagehandlerfactory, Ajax"/>






Third, add the following code to the Page_Load event of the page:



Ajax.Utility.RegisterTypeForAjax (typeof (WebForm1));



Here, the page is ready to use Ajax.







You can write a function in the background code and call it on the client. Like what:



[Ajax.ajaxmethod ()]



public int Serversideadd (int firstnumber, int secondnumber)



{



return firstnumber + secondnumber;



}



Here [Ajax.ajaxmethod ()] This sentence must be added. Otherwise there is no way to use the client.



This way, the Serversideadd method can be used directly on the client. Like what:

function Add2 ()

{

var re=webform1.serversideadd (Form1.first.value,form1.second.value)

Form1.result.value =re.value;

}





We can see in JS, this service side of the method before also with a WebForm1, this is the page corresponding class name.

TXT file in the example just let you understand some of the role of Ajax, of course, there are more powerful. As a method used by the client, the return value can be not only a generic type such as int, string, but also a complex type such as a DataSet and class, which also provides the potential for "strong JavaScript" for the client, allowing developers to " Object-oriented "development.

At the same time, no refresh in Ajax is one of its bright spots. The famous component Componentart a new 3. 0 products, there are call-back components, you can try if you are interested.





Of course, Microsoft also has Ajax products: Atlas

Detailed information can refer to:

asp.net "Atlas" Preview documentation

Related Article

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.