views:

53

answers:

2

Does anyone know how to do this? Specifically I have two arrays and some floating point numbers in an aspx.cs file and want to use it for a web silverlight app (xaml.cs).

Thanks for the help!

+1  A: 

Well, depending on size you may be able to format them as strings, pass them in as initParams, then parse the strings back into the arrays. It's a round-about process but I think your best bet for communicating directly between aspx.cs and silverlight.

The following link will describe in detail using init params: http://www.silverlightshow.net/tips/How-to-pass-initialize-parameters-to-Silverlight-application-using-ASP.NET-3.5-Silverlight-control.aspx

That said, if the amount of data grows much, you might consider looking at using a simple web service to manage the data.

If you need to communicate with the aspx page dynamically (I mean, more than just when the page loads), it is possible to use javascript to call methods in silverlight with the [ScriptableMember] attribute.

Peter Leppert
@peter do you know how I would use the ScriptableMember?
cfarm54
I only say that because I want it to be dynamic
cfarm54
+1  A: 

Ctrl + C -> Alt + Tab -> Ctrl + V

If you have code in one, and want to use it in another, either build your solution in a modular fashion so that both can reference a shared library of common objects and settings, or just copy and past your code.

md5sum
+1 because sometimes copy/paste is your best friend.
Chris Lively
@md5sum lol. aside from copy/paste, i'd like to reuse code
cfarm54
If you want to re-use the code, then you'll need to build your components out modularly, so that you'll have individual projects that you can share across different solutions.
md5sum
in what way would you suggest that i do this between xaml.cs and aspx.cs?
cfarm54
The way that I've always done this is to have a project called "Shared" (MySolution.Shared.dll) that has any code that is used by any clients, servers, and web sites. So in your entire solution, you can have MySolution.WebApp (the aspx stuff), MySolution.WpfApp (a standalone WPF application), MySolution.SlApp (the silverlight app), MySolution.Server (for a server app if needed), and MySolution.Shared (for all the things that all the apps use. You can obviously separate them however you need/want, just use something that makes sense in your context.
md5sum