Dear JS-Support,
javascript function How to call c# code (method or property)?
Thank you.
Regards,
Tomny
Code: Select all
void Test()
{
CSHTML5.Interop.ExecuteJavaScript(@"
// This is JavaScript code
alert('Hello from JavaScript');
// Let's call the C# method "MyCSharpMethod". Due to the fact that it is passed as the first parameter to this ExecuteJavaScript call, we can access it with $0:
$0();
", (Action)MyCSharpMethod);
}
void MyCSharpMethod()
{
System.Windows.MessageBox.Show("Hello from C#");
}
Code: Select all
CSHTML5.Interop.ExecuteJavaScript ("window.method1 = $0", (Action)MyCSharpMethod);
Users browsing this forum: No registered users and 3 guests