[C#] How to call eachother between WinForm and WebControl
//C# -----------------------------------------------
...
using System.Security.Permissions;
...
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class MainForm : Form
{
...
public MainForm()
{
...
webBrowser1.ObjectForScripting = this;
}
...
// Javascript -> WinForm
public void FunctionFromHTML()
{
...
}
...
// Winform -> Javascript
public void CallJavascriptFunction()
{
webBrowser1.Document.InvokeScript("FunctionFromWinForm", new object[]{ "text" });
}
}
//HTML -----------------------------------------
//Javascript -> WinForm
window.external.FunctionFromHTML();
// Winform -> Javascript
function FunctionFromWinForm(v)
{
...
}