I want to add a silverlight control to a div panel at runtime (dynamically) ( on an aspx or user control) . How can one achieve this?
Use this to create plugin dynamically
function createSL(pathToXAP, parentElement) {
Silverlight.createObjectEx(
{
source: pathToXAP,
parentElement: document.getElementById(parentElement),
id: "sltest",
properties: { width: "100%", height: "100%", background: "white", version: "4.0.50401.0" },
events: { onError: onSilverlightError }
});
}
pathToXAP -eg '<%= ResolveUrl("~/ClientBin/MySilverlight.xap") %>' parentElement is div's name
This function you can call from JS or from Silverlight as you need
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.