trbaphong
trbaphong

Reputation: 1623

Call winform function from html page?

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

Upvotes: 0

Views: 828

Answers (1)

Angshuman Agarwal
Angshuman Agarwal

Reputation: 4866

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

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

Upvotes: 1

Related Questions