Visual Basic .NET » ASP.NET General Discussion
Passing Ajax.Web.Dictionary ? -- eLad --


I have tried to do so by:

var dic=new Ajax.Web.Dictionary();
dic.add("x",1.2);

alert(SomeServerMethod(dic).value);
// server side

public bool SomeServerMethod(Dictionary<IJavaScriptObject,IJavaScriptObject> o){
return true;
}

but on every call i get

Message Object reference not set to an instance of an object.

Type System.NullReferenceException

Stack
at AjaxPro.JavaScriptDeserializer.Deserialize(IJavaScriptObject o,
Type type)
at AjaxPro.XmlHttpRequestProcessor.RetreiveParameters()
at AjaxPro.AjaxProcHelper.Run()
TargetSite System.Object Deserialize(AjaxPro.IJavaScriptObject,
System.Type)

Source AjaxPro.2

How can i send such a dictionary?

Thanks!

-- MichaelSchwarz --


Hi,

I have found a problem when using your code. I will publish an updated version in a couple of hourse. Thank you for your feedback!

Regards,
Michael
On 7/10/06, eLad <elado7> wrote:

I have tried to do so by:

var dic=new Ajax.Web.Dictionary();
dic.add("x",1.2);

alert(SomeServerMethod(dic).value);
// server side

public bool
SomeServerMethod(Dictionary<IJavaScriptObject,IJavaScriptObject> o){
return true;
}

but on every call i get

Message Object reference not set to an instance of an object.

Type System.NullReferenceException

Stack
at AjaxPro.JavaScriptDeserializer.Deserialize(IJavaScriptObject o,
Type type)
at AjaxPro.XmlHttpRequestProcessor.RetreiveParameters()
at AjaxPro.AjaxProcHelper.Run()
TargetSite System.Object Deserialize(AjaxPro.IJavaScriptObject,
System.Type)

Source AjaxPro.2

How can i send such a dictionary?

Thanks!
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- eLad --


Hey First of all, thanks for the reply !

I have just downloaded 6.7.11.1 and re-checked the code,
but still getting an error:

// client

var dic=new Ajax.Web.Dictionary();
dic.add("x","y");

ServerFunction(dic);

// server


public bool ServerFunction(Dictionary<string,string> dic) {
return true;
}
Message
Object reference not set to an instance of an object.

Type
System.NullReferenceException

Stack
at AjaxPro.JavaScriptDeserializer.Deserialize(IJavaScriptObject o,
Type type)
at AjaxPro.XmlHttpRequestProcessor.RetreiveParameters()
at AjaxPro.AjaxProcHelper.Run()

TargetSite
System.Object Deserialize(AjaxPro.IJavaScriptObject, System.Type)

Source
AjaxPro.2
also tried to replace <string,string> with
<IJavaScriptObject,IJavaScriptObject>, same error.

Thank you.

-- MichaelSchwarz --


Hi,

sorry, I did't fixed this bug, yet. I'm still over it, it is strange to create objects from generic types... I will give you a note if it is fixed. Please stand by...

Regards,
Michael
On 7/11/06, eLad <elado7> wrote:

Hey
First of all, thanks for the reply !

I have just downloaded 6.7.11.1 and re-checked the code,
but still getting an error:

// client

var dic=new Ajax.Web.Dictionary();
dic.add("x","y");

ServerFunction(dic);

// server


public bool ServerFunction(Dictionary<string,string> dic) {
return true;
}
Message
Object reference not set to an instance of an object.

Type
System.NullReferenceException

Stack
at AjaxPro.JavaScriptDeserializer.Deserialize(IJavaScriptObject o,
Type type)
at AjaxPro.XmlHttpRequestProcessor.RetreiveParameters()
at AjaxPro.AjaxProcHelper.Run()

TargetSite
System.Object Deserialize(AjaxPro.IJavaScriptObject, System.Type)

Source
AjaxPro.2
also tried to replace <string,string> with
<IJavaScriptObject,IJavaScriptObject>, same error.

Thank you.
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- eLad --


Ok,
That's great, thanks.

I just want to pass an object {name:"foo",type:"bar",number:7.62} and read it as a Hashtable or so (o
.ToString()=="foo" /
((double)o
)==7.62D). Is it possible anyhow?
Meanwhile I pass an Ajax.Web.DataSet.

-- MichaelSchwarz --


You can use following code instead:
var o = new Object();
o.name = "foo";
o.type = "bar";
o.number = 7.63;

AjaxClass.AjaxMethodX( o, mycallback );
On the server-side code use:


public static string AjaxMethodX(JavaScriptObject ht)
{
return ht
.Value;
}
Regards,
Michael

On 7/11/06, eLad <elado7> wrote:

Ok,
That's great, thanks.

I just want to pass an object {name:"foo",type:"bar",number:7.62} and
read it as a Hashtable or so (o
.ToString()=="foo" /
((double)o
)==7.62D). Is it possible anyhow?
Meanwhile I pass an Ajax.Web.DataSet.
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- eLad --


That's great.

Some little questions:
Why does strings comes out with quots?
And is there a way to send a datetime in a JavaScriptObject?

This is the o
.Value new Ajax.Web.Dictionary("System.Collections.Generic.Dictionary`2[[System.String,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089],[AjaxPro.IJavaScriptObject, AjaxPro.2,
Version=6.7.11.1, Culture=neutral,
PublicKeyToken=4735ae9824c7d3ec]]",
)

I tried also to use JavaScriptDeserializer.DeserializeFromJson<DateTime>(o
.Value)
but got an error.

You do great work. I appreciate it!

[Submit Comment]Home