locoboy
locoboy

Reputation: 38940

passing c# code from aspx.cs to xaml.cs

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!

Upvotes: 1

Views: 583

Answers (2)

Nathan Wheeler
Nathan Wheeler

Reputation: 5932

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 paste your code.

Upvotes: 1

PeterL
PeterL

Reputation: 1397

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.

Upvotes: 1

Related Questions