C# – Getting data out of a Silverlight control

asp.netcsilverlightsilverlight-3.0webforms

I am relatively new to Silverlight development and I am trying to figure out how to get data out of a silverlight control that I have made.

I have a Silverlight control that gathers a bunch of graphical data points. The Silverlight control is embedding in a asp.net webforms application. The page that is displaying the control also does other data specific functions and when the user clicks a button I need to perform some manipulation of the data (both webform data and the data contained in the Silverlight control) and then save the data with 1 call to the DB.

My question is how do I get the data out of the Silverlight control from my webform to be able to put the data together for the save?

My initial thought was to make the data in the Silverlight control accessible via Javascript and then on the button click, save the Silverlight control's data to some html control and then allow the regular webform post to occur and read the data server side. Is there a better way to do this as it feels a little messy.

Note: I am using .NET 3.5 and Silverlight 3.0.

Best Answer

You have a lot of options:

  • You can have your Silverlight control submit the data directly to the server, using ADO.NET Data Services or a webservice call which processes the data

  • You can use RIA Services, which simplifies the process of interacting with server-side code from Silverlight

  • You can have the Silverlight control update a form field (hidden, probably) which then can be processed and submitted via the web page

Related Topic