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;
    }
  }

15 Comments

  • Alan W. Cruz said

    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.

  • Charlie McKeegan said

    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

  • Michael Schwarz said

    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.

  • Charlie McKeegan said

    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.

  • Ryan said

    5.6.3.2 Should also support AjaxMethod constructors for accessing the session state and results caching. :) yipee

  • Michael Third said

    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

  • Michael Third said

    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

  • R. Drescher said

    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

Comments have been disabled for this content.