Ajax.NET Professional Demonstation Site

Michael Schwarz on Tuesday, August 30, 2005

I'm working on a first demonstration site for Ajax.NET Professional. Maybe you can help me to decide which examples you want to see: AutoComplete, Banners, HtmlUpdater, FormUpdater, ...

Ajax.NET Professional will allow you to use your objects as return values and as arguments without the need to write a IAjaxObjectConverter:

public interface IPerson { string FirstName{get;set;} }

public

class Person : IPerson { private string firstName; public string FamilyName; public int Age = 0; public double Depot = 0.0;    public Person() { // must have this constructor !! }

public Person(string firstName, string familyName) { this.firstName = firstName; this.FamilyName = familyName; }

region

IPerson Members    public string FirstName { get { return this.firstName; } set { this.firstName = value; } }

endregion

}

public class Boss : Person { public string CompanyName;

public Boss() : base() { // must have this constructor !! }

public Boss(string firstName, string familyName, string companyName) : base(firstName, familyName) { this.CompanyName = companyName; }

}

Now, we want to have a look at the Ajax.NET Professional method. The first method will return a IPerson object from a database. The second on will get this IPerson object from the client-side JavaScript to check if it is a Boss object.

[Ajax.AjaxMethod] public IPerson GetPersonFromID(int id) { if(id == 1) { Person p = new Person(); p.FirstName = "Michael"; p.FamilyName = "Schwarz";

return p; } else { Boss b = new Boss(); b.FirstName = "Hans"; b.FamilyName = "Mustermann"; b.CompanyName = "Your Company";

return b; } }

[Ajax.AjaxMethod] public bool IsBoss(IPerson p) { return p is Boss; }

[Ajax.AjaxMethod] public IPerson RefreshPersonObject(IPerson p) { p.FirstName = "Refreshed FirstName...";

return p; }