开发者

Adding silverlight control at runtime

开发者 https://www.devze.com 2023-01-22 19:13 出处:网络
I want to add a silverlight control to a div panel at runtime (dynamically) ( on an aspx or user 开发者_如何学JAVAcontrol) . How can one achieve this?Use this to create plugin dynamically

I want to add a silverlight control to a div panel at runtime (dynamically) ( on an aspx or user 开发者_如何学JAVAcontrol) . 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 -e.g. '<%= ResolveUrl("~/ClientBin/MySilverlight.xap") %>' parentElement is div's name

This function you can call from JS or from Silverlight as you need

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号