I want to know if I can use JavaScript in C#.Net Windows Form. If it can be used, how can I use that JavaScript.
5 Answers
No, javascript is a client scripting engine based on the Document Object Model (DOM) elements within a browser.
You list c# against this post, I'd suggest that you should invest some time learning LINQ for .net as this provides a DOM like query syntax for your windows forms. In fact, you can then query any .Net classes / objects.
Here's a link to the LINQ 101 examples;
4 Comments
You might want to check out Javascript.NET.
However, please make sure you are not trying to use javascript to solve a task much more easily solved with a more mainstream parts of the framework/c# language.
Comments
No. JavaScript needs a runtime environment. Such a runtime environment is present in browser, but not in Windows Forms.
In Windows Forms, you can use all the features of C# or any other programming language on the .NET platform. Hence, there is no need for a cross-browser, cross-platform language like JavaScript.
If you have an existing web application which have some functionality you would like to reuse, you could show it in browser frame within your Windows Forms application.
Comments
Not directly, but you can write/use an existing framework that handles this for you, and write some bindings to your UI or something. I've used http://jurassic.codeplex.com/ in the past, and its proven very efficient.
Comments
I found this helpful:
object result = this.Browser.InvokeScript("showOverlay", false);
For the full example: