Ajax
This is based on the demo written by the Ajax.NET author, the idea is to be able to submit a server-side definition from the client to the server side, the server can return a class to the client, I simplified the author's code, in the ASPX page does not use the CS file, while all the server-side methods are placed in a CS file In The code is annotated, and I find this AJAX framework really simple, as if now it looks like he's going to be simpler than Atlas and no refresh callbacks, all the code is IE6 and Firefox.
The front classtest.aspx code is as follows:
<%@ Page language= "C #"%>
untitled page
MyClass.cs file code: Only methods called by the client should add [Ajaxpro.ajaxmethod] to the method
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using Ajaxpro;
Summary description for MyClass
///
Namespace Mydemo
{
public class MyClass
{
Public MyClass ()
{
//
Todo:add constructor Logic here
//
}
public string FirstName = "";
public string LastName = "";
public int age = 0;
}
The following class inherits from the MyClass class, and he will have the same public properties as the class above
public class Myinheritedclass:myclass
{
public double Size = 0.0;
Public Guid gid = guid.empty;
}
public class Demo
{
Public Demo () {}
[Ajaxpro.ajaxmethod]
Public MyClass Getmyclass ()
{
This method will return an instance of the MyClass class
MyClass C = new MyClass ();
C.firstname = "Mouse";
C.lastname = "Wuqi Eva";
C.age = 30;
return C;
}
This method will be returned to the client with an instance of an inherited class Myinheritedclass class
[Ajaxpro.ajaxmethod]
Public Myinheritedclass Getinheritedclass ()
{
Initializes a Myinheritedclass class object because it inherits, so he also has the parent class public property
Myinheritedclass C = new Myinheritedclass ();
C.firstname = "Mouse";
C.lastname = "Wuqi Eva";
C.age = 30;
C.size = 4.5;
C.gid = Guid.NewGuid ();
return C;
}
The following method obtains data from the client (class object) and returns a class object to the client
[Ajaxpro.ajaxmethod]
Public MyClass Putclass (MyClass c)
{
C.lastname = "Wuqi Baby master";
return C;
}
}
}