The technique usually used for creating the Silverlight control is to call
Silverlight.createObject(...) from within a client-side script block just under the <div> element to be used as the host element. This has always bothered me since it felt rather fragile to expose embedded script directly within the form element on a page (for an ASP.NET page anyway).
It occurred to me today that the
pageLoad() method of ASP.NET Ajax is really the ideal place to create a Silverlight control for a page, since it is not invoked until the scripts have all been loaded, and the client-side DOM is in place. Here's an example of an ASP.NET Ajax page and the accompanying JavaScript file that loads a Silverlight control using this technique:
Now the page is free from any embedded script, and less susceptible to incidental errors introduced while doing layout - I like it!
Posted
Aug 01 2007, 02:33 PM
by
fritz-onion