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