如何从 aspx 页面访问 silverlight 控件的属性和方法?

发布于 2024-08-30 11:03:03 字数 121 浏览 7 评论 0原文

我正在开发一个网站,并且正在使用网络基础设施,但我想在某些页面中使用 silverlight 控件(也是基础设施)。有没有办法从 aspx 页面访问 silverlight 控件的属性和方法?

预先感谢您的帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

廻憶裏菂餘溫 2024-09-06 11:03:03

silverlight 控件在客户端上运行,因此访问 silverlight 控件数据的最佳方法是通过 javascript 方法公开。

您可以将 silverlight 控件中的属性和函数映射到 javascript 方法,然后根据需要调用它们。

如果您需要访问 silverlight 数据服务器端,那么您应该通过 javascript 公开您需要的内容,然后在回发之前调用 javascript 函数,并将其写入隐藏字段,以便您可以通过访问请求的发布的值。

要通过 javascript 公开您的一些数据,只需在 silverlight 页面中创建函数,如下所示:

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

然后您可以在客户端调用此函数并将其值写入隐藏字段,这将导致它与其余数据一起发布。

不久前,当我在做一个项目时,我问了一个类似的问题银光项目。

您可以做的另一件事(我不推荐)是让您的 silverlight 控件通过 Web 服务写回应用程序的会话或数据库,然后您的服务器端页面调用可以从您写入的任何位置读取数据。

要点是您需要某种类型的中间体来将数据返回到服务器,以便可以访问并且您希望某些东西是灵活的(隐藏字段方法是我的选择)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文