Ajax.NET is now supporting all build-in types

Sorry, I still forgot some types. Now, I added all build-in types. You can download the latest Ajax.NET Library at http://ajax.schwarz-interactive.de/. The current version is 5.6.3.1.

  [Serializable]
  public class MyClass
  {
    public int a = 9;
    public long b = 1;
    public short c = 2;
    public bool d = false;
    public string e = "Hallo";
    public char f = 'c';
    public string[] g = new string[]{"ssss", "aaaa"};
    public int[] h = new int[]{1,2,3,4,5};
    public byte[] i = new byte[]{100, 200};
    public byte j = (byte)100;
    public Guid k = Guid.NewGuid();
    public sbyte l = (sbyte)100;
    public decimal m = 200.5m;
    public double n = 1.7E+3;
    public float o = 4.5f;
    public uint p = 123U;
    public ulong q = 123UL;
    public object r = new object();
    public ushort s = (ushort)3.0;
    public char[] t = new char[]{'a','b','c'};
    public object[] u = new object[]{1, "a", 'c', true};
    public _data v;    // struct
    public MyClass w = null;

    [Serializable]
    public struct _data
    {
      public string A;
      public bool B;
      public int C;
    }

    public MyClass()
    {
      v.A = "Hallo";
      v.B = true;
      v.C = 99;
    }
  }

Published Friday, June 03, 2005 9:46 AM by Michael Schwarz

Comments

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 5:54 AM by Marcus
Have you published the source code or just binaries?

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 6:00 AM by Michael Schwarz
I have published the source code for the Ajax.NET examples and the compiled ajax.dll.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 9:18 AM by IO
Where did you say the source code was, sir?
Is this thing open source or not?

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 10:04 AM by Alan W. Cruz
AFAIK the source was going to be released but there where some problems with the gotdotnet workspace and Michael is currently in the process of finding a suitable place to release the code, in the mean time I would suggest you guys did what I did, build your own wrapper an come here for help until it is released.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 10:36 AM by Charlie McKeegan
Hi Michael,

First of, thanks for the cool framework, it really is very sweet. I am however having the StackOverflow problem when working with my own custom classes.

I think the problem is that fact that one of the classes uses an emumerated type like so:

public enum CompressionMethod {
cmNone,
cmZip,
}

This is occuring on your most recent release 5.6.3.1

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 10:57 AM by Michael Schwarz
I have fixed it already, what do you want to get from the enum??

public enum Color
{
Black = 1,
Yellow = 2
}


You can now get a string "Black", "Color.Black" or the value 1 as an integer.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 11:26 AM by Charlie McKeegan
Wow that was fast... I was hoping to get it as the string representation. So "Black" would be my preference.. makes it nice and easy to use in a select control.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 11:45 AM by Michael Schwarz
Download version 5.6.3.2 from http://ajax.schwarz-interactive.de/download/ajax.zip.

This version will support enums.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 12:29 PM by Charlie McKeegan
Sorry Michael, have you posted 5.6.3.2 for download? When I download the zip I still get 5.6.3.1

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 1:12 PM by Ryan
5.6.3.2 Should also support AjaxMethod constructors for accessing the session state and results caching. :) yipee

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 1:17 PM by Michael Third
I realize this is a simple request and can already be done with custom code, but how about make Hashtables deserialize to JavaScript sparse arrays? For instance:

// server side
Hashtable ht = new Hashtable();
ht["a"] = "stringa";
ht["b"] = "stringb";
return ht;


// browser
alert(response.value["a"]); // should return "stringa"

Right now it returns an array of {Key,Value} pairs.

Michael

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 2:10 PM by Michael Schwarz
The current public version is 5.6.3.2 available for download at my private website.

@Michael: this is not working in javascript (as I know).

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 2:23 PM by Michael Third
Last request (for this hour) .... when returning an XmlDocument from an AjaxMethod, the Response.ContentType is set to "text/html". This prevents the XMLHTTP object from parsing the response as XML. A simple change to "text/xml" fixes it.

Thanks,

Michael

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 2:45 PM by Michael Schwarz
Michael, thanks. I added the content already, but it was now a comment, I don't know why. I have fixed this and will release it in version 5.6.3.4.

# re: Ajax.NET is now supporting all build-in types

Friday, June 03, 2005 10:34 PM by IO
2 issues I just wanted to note

1. same name on the module and method does not work, i.e. <modulename>.<methodname> where <modulename> = <methodname>, boy this
took me like 2 hours to figure out

2. method overloading seems to be out of question

keep up the good work

# re: Ajax.NET is now supporting all build-in types

Tuesday, June 07, 2005 10:16 AM by R. Drescher
How can I use Session-Object with AJAX?

Thanx

Rene

# re: Ajax.NET is now supporting all build-in types

Tuesday, June 07, 2005 2:55 PM by Michael Schwarz
@Rene: please check my example at http://ajax.schwarz-interactive.de. You have to specify the HttpSessionStateRequirement:

[Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]

# re: Ajax.NET is now supporting all build-in types

Wednesday, June 08, 2005 3:21 AM by R. Drescher
Hi,

sorry, I've not correct read your example. Now I've next problem with costum type as arguments. On javascript create a array

var pp = new Array('Müller','Hans','Dresden','Schulze','Frauke','Berlin');

Then call the js-function

function test(p)
{
alert(p[0]);
var r = AjaxCall.test(p);
CallByAjax(r);
}

Serverside call the Ajax-function on codebehinde in the Page_Load

Dim c As AjaxCall = New AjaxCall
Dim ca As System.Collections.ArrayList = New ArrayList
ca.Add("Hallo")
ca.Add("Rene")
Response.Write(c.test(New ArrayList(ca)))

On Display is correct:
Calling ServerSide: Hallo - ParameterType = System.Collections.ArrayList

When I call the Ajax-Function over javascript, came the alert box with following return parameters

value: null
error : SyntaxError ';' erwartet
request :
context : undefined

I know this from remotescripting, but the serverside procedure works correctly.

Last the serverside call procedure:

<AjaxMethod(HttpSessionStateRequirement.Read)> _
Public Shared Function test(ByVal pp As Object) As String
Dim s As String = System.Web.HttpContext.Current.Session.SessionID
Dim strType As Object = pp.GetType
' Dim str As String = CStr(pp.GetValue(1))
Return String.Format("Calling ServerSide: {0} - ParameterType = {1}", CStr(CType(pp, System.Collections.ArrayList).Item(0)), pp.GetType.ToString())
End Function

What's the ERROR?

On your documentation your write:
The AJAX.NET wrapper on the server will check which converter can decode the Javascript object and passes the method a correct object. You can create your own IAjaxObjectConverters to allow every object to be returned or accepted.
...
Currently I have following IAjaxObjectConverters:
- System.Collections.ArrayList
- System.Data.DataSet/DataTable/DataRow
- System.DateTime/TimeSpan
- System.Array

Tanks

Rene