C# 在 IE 中托管用户控件
我们的网页仅在公司内部可用,我们非常有兴趣能够在 .Net 2.0 环境中在我们部门的网站上提供交互式 .net 用户控件。 我已经成功地嵌入了对象,如下所示:
<object id="Object1" classid="http:EmbedTest1.dll#EmbedTest1.UserControl1"
width="400" height="400">
<param name="TestStr" value="Test Param String" />
</object>
控件工作得很好,并且值已毫无问题地传递给控件。 但我在将后续值传递回嵌入式控件时遇到问题
尝试从控件接收事件:
尝试更新控件:
<script type="text/javascript">
function UpdateStr()
{
Object1.Text = "update string";
}
</script>
参考:
http://www.15seconds.com/issue/030610.htm
http://windowsclient.net/articles/iecommerce.aspx
问题:
- 这项技术已经过时了吗? - 如果是这样,是否有替代品
- 我应该只使用动作脚本而不是尝试这个吗?
- 我已经让它部分工作,我试图连接到我正在运行的网络服务,并且我得到了很多安全性异常...当我以相同的方式使用操作 scipt2 时,我没有得到相同的异常?
(旁注:-如何粘贴 html 脚本示例?)
谢谢。
布拉德
Our web page is only available internally in our company and we am very intrested in being able to offer interactive .net usercontrols on our departments website in the .Net 2.0 enviorment. I have been successful with embeding the object as so:
<object id="Object1" classid="http:EmbedTest1.dll#EmbedTest1.UserControl1"
width="400" height="400">
<param name="TestStr" value="Test Param String" />
</object>
The control worked just fine and the value was passed to the control without issue.
But I had a problem with passing subsequent values back to the embedded control
attempt to Recieve event from control:
attempt to update control:
<script type="text/javascript">
function UpdateStr()
{
Object1.Text = "update string";
}
</script>
Reference:
http://www.15seconds.com/issue/030610.htm
http://windowsclient.net/articles/iesourcing.aspx
Questions:
- Is this technology outdated? - if so is there a replacement
- Should I just work with action script instead of trying this?
- I have got this to partially work and I was attempting to connect to a webservice that I have running and I got many security exceptions...I didn't get the same exceptions when I used action scipt2 in the same manner?
(side note : - how do i paste html script examples?)
Thanks.
Brad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然很少使用,但并没有过时,并且仅限 IE。 如果您想要桌面应用程序的类似 Web 部署,请使用 ClickOnce。 如果您希望 C# 代码在浏览器中运行而不会出现安全问题,请使用 Silverlight。 您还可以查看 XBAP,它是在浏览器中运行的沙盒 WPF 应用程序,可在 IE 和 Firefox 上运行,但需要在客户端安装完整的 .NET,而 Silverlight 则不存在此问题。 底线:看看 Silverlight。
这当然是一个选择。 如果您更熟悉 Microsoft 堆栈,您应该尝试 Silverlight,您可以在浏览器中针对 .NET 框架的子集编写 C# 代码。
我们在内部网页中使用了 .NET 控件,并遇到了各种各样奇怪的问题,主要与脚本或安全性相关。 如果没有更多信息,很难确定问题。
ps 使用
Not out-dated so much as rarely used, and IE-only. If you want web-like deployment for desktop apps, use ClickOnce. If you want C# code that runs in the browser without security issues, use Silverlight. You could also look at XBAPs, which are sandboxed WPF apps that run in the browser, works on IE and Firefox, but requires the full .NET to be installed client-side, whereas Silverlight does not have this problem. Bottom line: look at Silverlight.
That's certainly an option. If you're more familiar with the Microsoft stack, you should try Silverlight, where you can code C# against a subset of the .NET framework right inside the browser.
We've used .NET controls in web pages internally and had a wide variety of strange issues, mostly related to scripting or security. Hard to determine the problem without more information.
p.s. write all code examples using the <pre> tags. There's a "code sample" button on the toolbar.
如果您使用 Windows 控件执行的操作可以使用 ASP.NET Web 控件完成,我建议您考虑切换。 您将更好地控制从客户端到服务器的信息交换。
If the things that you are doing with the Windows Controls could be done with ASP.NET web controls instead, I recommend that you consider switching. You'll have much better control over the exchange of info from the client to the server.
1, 2) 是的,它已经过时了。 如果您想在 .NET 中工作(并且您一心想拥有一个控件而不是 ASP.NET 样式的页面/站点),请尝试一下 Silverlight。
3) 在浏览器中运行的.NET 代码受到非常严格的安全控制(例如,无法回调到它不来自的网站)。
1, 2) Yes it is outdated. If you want to work in .NET (and you're bent on having a control rather than an ASP.NET-style page/site), give Silverlight a try instead.
3) .NET code running in the browser is subject to very strict security controls (can't call back to a web site it didn't come from, for example).