将JSON对象从Javascript发送到Silverlight,然后触发事件以更新Silverlight [英] Sending JSON Object from Javascript to Silverlight then triggering an event to update Silverlight

查看:95
本文介绍了将JSON对象从Javascript发送到Silverlight,然后触发事件以更新Silverlight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Web应用程序,该应用程序基本上由一组HTML表单组成,当用户更新它们时,它们会更新客户端Javascript Object Literal.然后,该对象文字将转换为JSON字符串,并传递到服务器以在提交表单时进行处理.

I am building a web application that basically consists of a set of HTML forms that, when the user updates them, updates a client-side Javascript Object Literal. That Object Literal is then converted to a JSON string and passed to the server for processing upon form submission.

用户填写表单->本地javascript更新客户端JS对象文字->用户按下提交-> JS对象文字转换为JSON对象-> JSON发布到服务器->服务器处理JSON对象 >

此应用程序的一部分包括表单内容的可视化.可视化非常简单,由一组同心圆组成.我目前正在使用HTML5 Canvas来创建该可视化效果,但是我想改变视角以利用Silverlight,因为我希望用更少的代码就能获得更好的跨浏览器结果.

Part of this application includes a visualization of the contents of the form. The visualization is very simple, consisting of a set of concentric circles. I am currently using HTML5 Canvas to create that visualization but would like to change the viz to utilize Silverlight as I would get better cross-browser results with hopefully less code.

我的问题是是否可以将JSON字符串发送到嵌入在我的客户端表单中的Silverlight应用程序,然后触发一个事件,一旦接收到JSON对象,该事件即更新了viz ...全部都没有页面重新加载.

My question is if it is possible to send a JSON string to a Silverlight application that is embedded in my client-side form and then trigger an event that updates the viz once that JSON object is received...all without a page reload.

Silverlight和javascript甚至有可能吗?如果是这样,涵盖这一点的教程将非常有帮助.

Is this even possible with Silverlight and javascript? If so, a tutorial that covers this would be very helpful.

PS:如果使用Visual Studio 2010,那会有所不同.

PS: I am using Visual Studio 2010 if that makes a difference.

TIA

推荐答案

是的,您可以做到-

Yes, you can do that - the HTML Bridge is a feature in Silverlight which allows JS code to call SL functions and vice-versa. Take a look at the link above for more information.

这篇关于将JSON对象从Javascript发送到Silverlight,然后触发事件以更新Silverlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆