Page view counter
How to return javascript dictionary object to silverlight method ?
Last post 08-27-2008 2:40 PM by swildermuth. 1 replies.
Sort Posts:
08-19-2008 10:46 AM
How to return javascript dictionary object to silverlight method ?

How can i javascript dictionary object in Silverlight?

Javascript code

function GetStatus(contacts)
{
    var ht = {};
    if (contacts.length) {    
        for (var i=0; i < contacts.length; i++) {
           
            var foundContact = _communicatorObj.GetContact(contactsIdea, _communicatorObj.MyServiceId);
            alert(contactsIdea + ", " + foundContact.Status);
            ht[contactsIdea] = foundContact.Status;
        }
    }

    alert(ht.toString());
    return ht;
}

Silverlight

Dictionary<string, object> statusDic = HtmlPage.Window.Invoke("GetStatus", jsContacts) as Dictionary<string, object>;

statusDic is always null!

as i know, Javascript dictionaries can be converted to Dictionary<string, object>.

http://msdn.microsoft.com/en-us/library/cc645079(VS.95).aspx

How can i this?

narzis

Loading...
Joined on 06-24-2008
Seoul
Posts 7
08-27-2008 2:40 PM
Marked as Answer
Re: How to return javascript dictionary object to silverlight method ?

I think this is a bug in Beta 2.  Hopefully it'll be fixed in the Release.  I found this same behavior when I was writing a wrapper for GoogleGears.

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 2 Workshop
November 19-21, 2008 - Seattle, WA
December 1-3, 2008 - Dallas, TX
http://silverlight-tour.com

swildermuth

Loading...
Joined on 10-13-2003
Atlanta, GA
Posts 1,246
Microsoft Communities