System.Data.DataSet/DataTable and System.DateTime using Ajax.NET Wrapper DLL

The feedback for my last Ajax.NET Wrapper DLL was very good. I got a lot of new ideas, thank you!!

Now, I changed the javascript that will be created with the wrapper. It will be a little bit smaller, but there will be more changes to save more bytes in the future.

On thing the users asked for was to return System.Data.DataSets or DataTables to the client. I have done my first sample and I am very happy to present the next release that will return DataSets and DataTables as a Javascript object. The syntax will be nearly the same as in .NET. I have added some code to the sample project at http://ajax.schwarz-interactive.de/csharpsample/. Feel free to play around, have a look inside the HTML/Javascript code and download the sample project and Ajax.NET Wrapper DLL for free.

The second thing was to export any class. The first way was to mark the classes with attributes. Now, you do not have to mark these classes. Use your own .NET classes as you have done in the past.

The next missing feature was returning arrays. In the sample project I have added a method that will return a small class that will have a array. The C# code looks like this:

public class Address
{
    public string
Firstname = "";
    public int
Age = 0;
}

public class
MyClass
{
    public
DateTime TimeStamp = DateTime.MinValue;
    public Address[] Addresses = new
Address[2];
}

The Javascript code is very similar to the code in .NET. Have a look at the callback function in Javascript:

alert(res.Addresses.length);
alert(res.Addresses[0].Firstname);

Some users didn't know why to add a callback instead of calling the method direct. I have used callbacks to use the methods asynchron. If you call a method that will need some seconds until finished the browser will hang for this time!

You can also use the System.DateTime in your code!

3 Comments

  • Mathias said

    This works for me...Thank you.
    I have a question about asynchronous requests. If I call checkUsername and within 1 second getDataSet only getDataSet is executed. Is this a limitation of your implementation or always the case in XmlHttp? It might sound not so important, but I have some forms with lots of elements on them and processes migth take realy long. Then this realy gets a problem.

  • Michael Schwarz said

    Hi Mathias, of course, this is not a problem of XmlHttpRequest. At the moment I only allow one request per class, but it is very simple to change that. I had some problem in the past with the Internet Explorer memory but this is fixed in the next release.

    CIAO
    Michael

Comments have been disabled for this content.

Twitter

In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: DieApfelFamilie