Saturday, August 4, 2007

Silverlight and ASP.NET

Lately I have looked into Silverlight - the new plugin from Microsoft. The 1.1 version is currently in beta, and it all looks very good!

If you create a Silverlight project in Visual Studio Orcas (the next version), you only get a html-page called testpage.html

The test page is intended as just what it says - its a test page. The Silverlight project is basically a variant on a class library project, just targetting Silverlight.

The way to work with websites and Silverlight is to add a web site or web application project to the solution. Right clicking on a directory in either of those will show an "Add Silverlight link" command. This will then add the outputs of the silverlight project to the site, and update them on builds etc. Consider it similar to add reference, but the output doesn't go in the bin directory as its run on the client, not the server.

If you drag a xaml file onto the design surface it will create a xaml asp.net control for you. This ends up with a "Click to activate" message when you run the page. Haven't figured out a good way to remove that yet...

One solution is to just write out the Silverlight control using javascript as used in the testpage.html. There is a demo of this method here: http://silverlight.net/QuickStarts/ViewSample.aspx?sref=SilverlightSampleControl/cs/Default.html, but it should be a better option...!

0 comments: