I've created a serialized class to represent an object I want to use
within Ajax.Net. I want to create an AjaxMethod function that accepts
an array of those objects, like so:

 <Ajax.AjaxMethod()> Public Function FilterSearch(ByRef
myCustomObjectsArray() As FilterSearchParameter) As String

'Do Stuff

End Function


The javascript I'm using does something like this:

AjaxMethods.FilterSearch( [ new FilterSearchParameter(1), new
FilterSearchParameter(2) ], myCallBackFunction );

But it doesn't seem to work. It seems to be able to create the
FilterSearchParameter objects within the javascript, but trace is
showing me these errors:

HandleException
The method or operation is not implemented.
  at Ajax.JSON.DefaultConverter.FromString(String s, Type t)
  at Ajax.AjaxProcessor.RetreiveParameters(StreamReader& sr,
ParameterInfo[] para, Object[]& po)
  at Ajax.AjaxRequestProcessor.Run() 0.00204203061748104 0.002042
Ajax.NET Invoking Pipeline2006.AjaxMethods.FilterSearch
0.00257694851473858 0.000535
Ajax.NET HandleException
Object of type 'System.DBNull' cannot be converted to type
'Pipeline2006.AjaxMethods+FilterSearchParameter&'.
  at System.RuntimeType.CheckValue(Object value, Binder binder,
CultureInfo culture, BindingFlags invokeAttr)
  at System.Reflection.MethodBase.CheckArguments(Object[] parameters,
Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature
sig)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean skipVisibilityChecks)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
  at Ajax.AjaxRequestProcessor.Run()


Also, upon callback, the results object contains the error:
"SyntaxError Expected ';'"

Here's the converter class I've created. This is the first one I've
written, so there could be a problem here.

Public Class FilterSearchParameterConverter
        Implements Ajax.JSON.IAjaxObjectConverter

        Public ReadOnly Property ClientScriptIdentifier() As String
Implements Ajax.JSON.IAjaxObjectConverter.ClientScriptIdentifier
            Get
                Return "AjaxFilterSearchParameter"
            End Get
        End Property

        Public Function FromString(ByVal s As String, ByVal t As
System.Type) As Object Implements
Ajax.JSON.IAjaxObjectConverter.FromString
            System.Web.HttpContext.Current.Trace.Write("s:" & s & "----
t:" & t.Name)
        End Function

        Public ReadOnly Property IncludeSubclasses() As Boolean
Implements Ajax.JSON.IAjaxObjectConverter.IncludeSubclasses
            Get
                Return False
            End Get
        End Property

        Public Sub RenderClientScript(ByRef sb As
System.Text.StringBuilder) Implements
Ajax.JSON.IAjaxObjectConverter.RenderClientScript
            sb.Append("function FilterSearchParameter(ParameterID,
Criteria){this.ParameterID = ParameterID; this.Criteria = Criteria;}")
        End Sub

        Public ReadOnly Property SupportedTypes() As System.Type()
Implements Ajax.JSON.IAjaxObjectConverter.SupportedTypes
            Get
                Return New Type() {GetType(FilterSearchParameter)}
            End Get
        End Property

        Public Sub ToJSON(ByRef sb As System.Text.StringBuilder, ByVal
o As Object) Implements Ajax.JSON.IAjaxObjectConverter.ToJSON

            Dim p As New FilterSearchParameter()

            If o.GetType() Is GetType(FilterSearchParameter) OrElse
o.GetType() Is GetType(FilterSearchParameter) Then
                p = CType(o, FilterSearchParameter)

                sb.Append(" new FilterSearchParameter(" & p.ParameterID
& ", '" & p.Criteria & "') ")

            End If
        End Sub
    End Class

This is registered in the Application_Start method with:

Ajax.Utility.RegisterConverterForAjax(New
AjaxMethods.FilterSearchParameterConverter)

Any suggestions? Do I need to do something to make Ajax.Net accept
arrays of custom objects, such as write a collection class for my
object? How would I make use of that from within the Javascript?

Let me know if more info is needed. Sorry for the long post...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to