Javascript methods and class libraries provided by Microsoft ajax

Source: Internet
Author: User

Over the past few days, I have been looking at the content in ASP. NET AJAX asynchronous calls to Web Services and webpage class methods, which is indeed very powerful, so that we can develop some ajax functions asynchronously. For details, go to Dflying Chen @ cnblogs's blog.

What I want to talk about today is that there is a pageload method in the background of the apsx page to load the function we want to execute for the first time. In fact, on the page, javascript also has a pageLoad method, the javascript code to be executed during page loading is easy to use. You can directly put it in <script>.

The Code is as follows:

Function pageLoad (){

// Call the methods in web service asynchronously

WebApplication1.WebService1. GetGenericEmployeeDictionary (onSucceeded );

}

 

We know that Microsoft has created many class libraries for us in ajax, many of which were originally class libraries in c # And are encapsulated in javascript, it is convenient for us to use in the development process.

For example, StringBuilder class

Var tableBuilder = new Sys. StringBuilder ("<table border = 1> ");

// Create a table heading row

TableBuilder. append (

"<Tr> <td> Id </td> <td> Name </td> <td> Email </td> <td> Salary </td> </tr>"

);

For (var key in result ){

Var employee = result [key];

// Create a table content row

Var rowString =

String. format (

"<Tr> <td >{0} </td> <td >{1} </td> <td >{2} </td> <td >{3} </td> </tr> ",

Employee. Id,

Employee. Name,

Employee. Email,

Employee. Salary

);

TableBuilder. append (rowString );

}

TableBuilder. append ("</table> ");

$ Get ("result"). innerHTML = tableBuilder. toString ();

 

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.