webBrower中的加载的页面,激活winform的相应事件

在网页中添加对应的JS

<script type="text/javascript">

window.onload=function(){

var btn=document.getElementById('btnCallCSharpMethod'); //网页中触发事件的控件id
btn.onclick=function(){

window.external.ShowMessage('需要传递的内容');//ShowMessage  winform端接收的方法

}

}
</script>

winform端

public void ShowMessage(string weburl)
{
string webUrl = weburl;
//调用系统默认的浏览器
System.Diagnostics.Process.Start(webUrl);
}

 

posted @ 2017-07-31 17:24  金角大王问君名  阅读(243)  评论(0编辑  收藏  举报