Search code examples
asp.netvb.netsilverlightsilverlight-3.0vs-web-application-project

How to embed a SilverLight control in ASP.NET control (user or custom)


We have a ASP.NET web application written in VB.NET where we build content programmatically during the Init event.

We make extensive use of user controls, building them on the fly, and I now want to start including SilverLight content.

Is there an easy way of embedding a SilverLight application in a control, and then instantiating the whole thing in code, in the same way as you'd programmatically add ordinary ASP.NET controls to a page?

The SilverLight component itself works fine when added to a page using the <object> tag but I really want to be able to reuse it elsewhere in code.

Since I'm expecting use of SilverLight to increase in our application, and the asp:Silverlight control seems now to be deprecated, I'm looking for an alternative way of wrapping the content.

Thanks for any pointers.


Solution

  • You can make your own version of the deprecated Silverlight control - all it has to do is emit the appropriate <object> html during its Render event. This is a really straight forward 5 minute task to roll one of these up.