2

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.

1
  • 6
    What do you want to use it for? Commented Jul 1, 2011 at 8:12

5 Answers 5

2

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;

http://msdn.microsoft.com/en-us/vcsharp/aa336746

Sign up to request clarification or add additional context in comments.

4 Comments

Javascript is not a client scripting engine. It is primarily used as one, but it doesn't care if there's DOM around or not.
@GSerg: True, however I was trying to simplify things a little for the original poster who's clearly confused about client / server side languages. +1
Well, C#, when referred to in context of Windows.Forms, is a client-side language, too. So the question starts making sense after all. There are desktop apps out there written in JavaScript.
What does LINQ have to do with JavaScript again?
2

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

1

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

0

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

0

I found this helpful:

  object result = this.Browser.InvokeScript("showOverlay", false);

For the full example:

https://weblog.west-wind.com/posts/2008/sep/27/calling-javascript-functions-in-the-web-browser-control

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.