rlcrews
rlcrews

Reputation: 3562

How to pass objects between silverlight and asp.net

I have seen examples where you can pass parameters between aspx and silverlight app as well as how to pass simple values back to aspx.

Is it possible to pass generic types such as list collections from a silverlight app to a asp.net page to be picked up. I have looked at serialization but not sure if this is the best approach due to performance?

Thanks in advance

Upvotes: 1

Views: 1223

Answers (3)

Brian Genisio
Brian Genisio

Reputation: 48127

Since Silverlight is client-side and ASP.Net is server-side, you will need to use serialization in order to pass objects between the two.

I would consider using the DataContractSerializer in Silverlight to serialize the object as XML. You can then push the XML up any way you want: ASPX web service, WCF service, HTTP PUT, Hidden fields in the HTML, etc.

Upvotes: 0

PjL
PjL

Reputation: 982

You can also communicate with your .aspx page client-side, through scriptable objects... see HtmlPage.RegisterScriptableObject(string, object) in Silverlight documentation.

Upvotes: 2

user384929
user384929

Reputation:

Review: Sharing C# code between Windows and Silverlight class libraries

Your Answer will be listed within that solution already provided for the same question or nearly exact.

Excerpt:

You cannot set a reference from a Silverlight assembly to a regular .NET assembly but you can do so the other way round.

So create a shared Silverlight assembly and add your code to that assembly. Now you can set a reference fro both your regular .NET and you other Silverlight assembly to the shared Silverlight assembly.

The restriction is that you can only put code in there that would work on both the .NET and Silverlight CLR but that is no different from sharing code.

Courtesy: Maurice

Upvotes: 0

Related Questions