开发者

How to access Silverlight client and server side?

I have a real basic Silverlight app consisting solely of a label within an ASP.NET web page. It is included as an object.

If I want to开发者_如何学编程 change the Silverlight's label content via a button placed on the ASP.NET page. Could anyone provide a sample on how to do this both via javascript and server side via c#?

Thanks.


Silverlight is a client-side technology, so you can't access it directly from server.

However, you can use its scripting capabilities to achieve what you want. For instance, you ASP.NET button could write some javascript which will interact with you SL app.

// Silverlight code
[ScriptableMember]
public void Start()
{
    // do something
}

// Javascript code
function start() {
    if (confirm("Are you sure?")) {
        document.getElementById("<%= SilverlightUpload.ClientID %>")
                .content.myControl.Start();
    }
}


Silverlight and JavaScript Interop Basics

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜