views:

320

answers:

4

Hi!

I wondering if a can make a form with silverlight like an HTML form and submit its data to a server to store them on a database.

Can I do that?

Thanks!

+1  A: 

You can always host the sliverlight app in a web page which the forms app loads.

It may be possible to directly intergrate WPF and forms as well.

Jason Coyne
+2  A: 

Just take a look at some videos over here:
http://silverlight.net/learn/videocat.aspx?cat=2#HDI2WebServices
basically, you build your data model with Linq (or some other orm), expose that data through Select/Update/Delete/... methods with web service (new WCF or old one, ASMX), and consume that in silverlight. Silverlight automatically make proxy classes for communication. In Silverlight, you can use it's rich databinding capabilities, so you do not need to worry about how data are transferred, serialized, read from UI and similar.
Video tutorials on silverlight.net web explains most of stuff regarding programming SL2 really good.

Hrvoje
+6  A: 

You can definately do this. But you cannot talk to a server directly via Silverlight like you can with ASP.Net. You have to use web services to achieve this.

There are a number of ways to do this:
1. Use Web Services (Old ASMX; This has security issues)
2. Use WCF (For complex systems)
3. Use ADO.Net Data Services (This is probably the easiest and fastest way to achieve this) using ADO.Net Entity Framework.
4. Use RIA Services (In CTP now for Silverlight 3)

irperez
+1  A: 

Or you aren't running ASP.NET on the server like everybody always seems to assume you are and therefore don't use all these darned "Web Service" things, you can just use WebClient and make your POST that way.

...I dont know why everybody thinks there is a need to layer on so many heaps of acronym goo between you and your webserver. Your old javascript code wasn't interfacing with your backend using WCF, SOAP or whatever, why should Silverlight? Keep it simple! Silverlight is more than happy to make regular, old-fashioned, time-tested HTTP POST's.

And not to be shameless, I've been working on a library I use in my projects to make it easier to call your backend like you would have if you were using javascript: WebBuddy.

Cory R. King