My Ajax Server framework-(3) JS call PAGE Method

Source: Internet
Author: User

Note: the framework described in this article has a new version,Click the link below to read.
[Write your own ASP. net mvc Framework]

Return to the directory: bask in my Ajax Server framework

This function allows you to directly call a C # method on the current aspx page in Javascript. The sample code is as follows:

C # Method

Public partial class Customers: MyBasePage {// <summary> // For AJAX call: Update customer information. For details about the call method, refer to the JS Code. /// The method can be static or not. /// </Summary> /// <param name = "customer"> </param> /// <returns> </returns> public static int UpdateCustomerInfo (Customer customer) {customer. ensureItemIsOK (); return BllFactory. getCustomerBLL (). update (customer) ;}} public sealed class Customer: MyDataItem {public int CustomerID {get; set;} public string CustomerName {get; set;} public string ContactName {get; set;} public string Address {get; set;} public string PostalCode {get; set;} public string Tel {get; set ;}}

Javascript call code

$. Ajax ({type: "POST", // note parameter: AjaxPageMethod, which specifies the method to call the page. Data: $. param ({AjaxPageMethod: "UpdateCustomerInfo", CustomerID: customerId}) + "&" + $ ("# divCustomerInfo: text "). fieldSerialize (),//......});

The following configurations are also required for the above functions:

When the preceding JavaScript code is running, it submits the current page to the UpdateCustomerInfo method of the current MERs. aspx page in AJAX mode.

Now, this demo is written here. For more details, see the user manual.

Return to the directory: bask in my Ajax Server framework

Click here to go to the demo and download page

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.