by Kunal Chowdhury via Kunal's Blog on 1/19/2012 10:00:00 PM
We all know the process to embed a Silverlight application inside a Webpage using div and object tag. When we create a new Silverlight application project, those tags automatically generates by the IDE inside the html and aspx pages. In many cases we need to dynamically add the Silverlight application inside a webpage. In this post, we will learn the process to host it using JavaScript. Looks interesting? Read to know more.
<div id="silverlightControlHost"> <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/SilverlightApplication1.xap" /> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="4.0.60310.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0" style="text-decoration: none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> <iframe id="Iframe1" style="visibility: hidden; height: 0px; width: 0px; border: 0px"> </iframe> </div>
<div id="silverlightControlHost"> <script type="text/javascript"> Silverlight.createObject( "ClientBin/SilverlightApplication1.xap", // source silverlightControlHost, // parent element "slPlugin", // id for generated object element { width: "100%", height: "100%", background: "white", version: "4.0.60310.0" }, { onError: onSilverlightError }, "context" // context helper for onLoad handler. ); </script> </div>
Original Post: How to host a Silverlight Application using JavaScript?
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.