开发者

How to access a silverlight control's properties and methods from an aspx page?

I'm developing a web site开发者_高级运维, and i'm using infragistics for web, but I want to use in some pages silverlight controls (Infragistics too). Is there a way to access a silverlight control's properties and methods from an aspx page?

Thanks in advance for the help.


The silverlight control is running on the client so the best way to access the silverlight's control data is by exposing via javascript methods.

You can map your properites and functions in your silverlight control to javascript methods and then call them as needed.

If you need access the silverlight data server side, then you should expose what you need via javascript and then call the javascript function before a postback and have it write values to a hidden field so that you can then retrieve them server side by accessing the request's posted values.

To expose your some data via javascript just create function in your silverlight page like:

[ScriptableMember]
public int GetValueFromSilverlight()
{
    // lame example
    return int.Parse(textBox.Value);
}

You could then call this function client side and write it's values to a hidden field which will cause it to post along with the rest of your data.

I asked a similar question a while back when I was working on a silverlight project.

Another thing you could do (which I don't recommend) is to have your silverlight control write back to the application's session or database via web services and then your server side page calls can read the data from whatever location you have written to.

The main point is your need some type of intermediate to get the data back to server so it is accessible and you want something is flexible (hidden field method was my choice).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜