i want to use AJAX and javascript in window platform ...can i use it in vs 05 C# window?
-
hy would you want to do it in a winform?Itay Moav -Malimovka– Itay Moav -Malimovka2009-05-26 15:23:17 +00:00Commented May 26, 2009 at 15:23
-
yup i want to do it in window formShamim– Shamim2009-05-26 15:25:14 +00:00Commented May 26, 2009 at 15:25
-
4But why? There are other ways to do async HTTP request from C#.Jakob Christensen– Jakob Christensen2009-05-26 15:27:46 +00:00Commented May 26, 2009 at 15:27
-
2Why, why oh why? Winforms allows on demand C# code which allows so much more than Javascript and AJAX.cjk– cjk2009-05-26 15:34:46 +00:00Commented May 26, 2009 at 15:34
-
jflkjdkfjkljsafkjklsf fjksjfdkShamim– Shamim2009-05-26 15:51:10 +00:00Commented May 26, 2009 at 15:51
5 Answers
The options I know about:
- JSC.exe
You can compile Javascript into a managed assembly, and call it as you would any .NET assembly. - COM
You can package Javascript logic as COM, and call it from .NET, or from any COM environment. Example.
EDIT: This allows Javascript, but not AJAX. AJAX is a term that specifically applies to browsers, primarily using Javascript to retrieve information and potentially dynamically update the browser page without an explicit page refresh. This generally doesn't make sense in a Windows Form app built in C#, because you have C#, and asynchrony is built in to the .NET platform.
4 Comments
Erm - AJAX is just the name for the techonologies and patterns used to make HTTP requests in Javascript. Javascript itself will run in any Javascript engine; most browsers embed one, and you can also use the Rhino standalone engine (though a lot of Javascript will assume a browser environment, which can get flaky).
C# is not Javascript, and to my knowledge, Visual Studio is not a Javascript interpreter. Why are you trying to do this?
2 Comments
You can just add a System.Windows.Forms.WebBrowser to your app, navigate it to whatever HTML + JS page you want, and do all the AJAX you want there.
1 Comment
You cannot use JavaScript/JScript to write code as part of a Windows Forms Application. It seems you are after asynchronous data transfer functionality (posh ;) / AJAX which will need to be implemented seperately. Alternatively, if you are looking to provide a scripting language to your users, try IronPython
For a more detailed answer, state in the question the specific part of JavaScript you would like to use, and we'll give alternatives.
EDIT: Oh. You can! Look at the answer above.