从html页面调用winform函数? [英] Call winform function from html page?

查看:478
本文介绍了从html页面调用winform函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含c#webbrowser控件的winform应用程序.Webbrower控件加载一个html页面。在那个html页面上我有一个按钮。我想要的是当点击那个按钮时,它会调用一个winform函数(例如Form1.cs中的函数)。可能吗?请帮我

I have a winform application that contains a c# webbrowser control.Webbrower control load a html page. On that html page I have a button. What I want is when click that button, it will call a winform function(function in Form1.cs for example). Is it possible? Please help me

推荐答案

使用的 window.external 对象在您的脚本代码中访问指定对象的公共属性和方法。 (请参阅示例链接)

Use window.external object in your scripting code to access public properties and methods of the specified object. (See the sample in the link)

C#

public void Test(String message)
{
    MessageBox.Show(message, "client code");
}

HTML $ b

HTML

<button onclick="window.external.Test('called from script code')">
    call client code from script code
</button>

这篇关于从html页面调用winform函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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