Can i use javascript in C#.Net Windows Form? - c#

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.

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.

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

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.

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.

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

Related

how to use javascript or jquery in windows form?

I'm making this application in c#.net, just for personal use and I'm just making it for practice and to learn more about c#.net programming.
I know java script is meant for web applications, but maybe there are ways to use them in windows applications as well.
No you can't use them directly.
You could technically make a library that parses JQuery and does the same things... or you could make a C# equivalent of the same functionality, but that seems like more work than it's worth.
If you are looking to practice c#.net then practice c#.net, even if you could use javascript/JQuery that wouldn't get you much c# practice would it.
Regular windows (desktop) applications will not run on javascript.
However, windows 8 store applications (either for windows 8 desktop, or windows mobile) can be created using HTML5 & js.
This series should give you a decent start: http://www.microsoftvirtualacademy.com/training-courses/developing-windows-store-apps-with-html5-jump-start#?fbid=ldvGrgy_tPQ

Gesture-Controlling Javascript InfoVis Toolkit via C# (Kinect SDK)

I've been running around the web for a while now looking for a solution to this problem, but I'm quite disheartened by now to find something that will fit all of my requirements. So here goes.
I'm trying to build a desktop application that uses the Kinect for Windows sensor to control a visualization of digital library (as in, the place you go to for books) assets. I'm quite versed in using the official MS Kinect SDK and already have a neat utility framework for prototyping at hand, so I'd obviously love to make use of it. This plus the desktop app theme of things says the whole shebang will need to be in C#, which is fine by me.
On the other hand, the visualization part already exists and looks gorgeous, but it's JavaScript (and specifically, JIT i.e. javascript infovis toolkit). It has all the bells and whistles I need and it's neatly animated. Also, I'm a noob at JavaScript.
The point is, how do I avoid rewriting either one into the other's language while still allowing them to talk at runtime?
So, do you know any way to either
A) embed a JIT visualization (e.g. radial tree visualization) in a windows application in a way that allows me to manipulate the graph at runtime from a C# class (e.g. selecting a new node to be animated into focus) or
B) send C# events to JS to react to gesture input at runtime? Is this something ASP.NET can do?
I have a feeling the result will be a weird mix of desktop and web technology, but any pointers to the right sort of technology is greatly appreciated.
Maybe you should look at this projects about using Kinect with JavaScript:
http://research.microsoft.com/en-us/projects/kinectedbrowser/
http://kinesis.io/

Metro style apps with Html and C#

According to this slide
http://media.infragistics.com/community/general/windows8-platform-tools.jpg
Does it mean I have to use XAML view with C# if I want to develop a metro styled application?
Can I use a HTML/JS/CSS - C# combination with event handlers and all? Something like ASP.NET Webforms/MVC . I know it is not the same client server architecture, but since metro styled apps support HTML/JS, I was wondering.
I can use Win-JS. But can I rather write C# than Javascript, and use HTML rather than XAML?(I dont know XAML and I like C#)
All the C# samples I found online use XAML.
Perhaps you can write portions of your program logic in C# and package it as a library and then create a HTML5/JS app that references the C# Library. That way you should only need to use JS for the parts that are directly related to UI functions and C# for the rest.
I will point out that I haven't tried it yet, but Bill in this thread says that he got it to work.
No, you can only use XAML with C#, or HTML+CSS+JS. But XAML is great markup language, so I think you able to use it.
You can create a "WinMD" library in c# (or c++) that can be invoked from JavaScript. There are a ton of limitations that WinMD libraries have over normal .net libraries and the usage model would be would at all like ASP.NET MVC. Frankly, unless you have a lot of business logic in c# already or if you want to reuse a bunch of code in Win8 Metro apps spanning both HTML and XAML, this WinMD thing is more hassle than its worth.
According to MSDN - Dev Center - Metro style apps you can use C#/VB/C++ and XAML and JavaScript and HTML5 to develop a metro styled application (for Windows8/WindowsPhone).

Embed html in C# Forms

Is there a way to embed HTML into a windows forms custom usercontrol? I want to create a lightweight control to be used in a .NET 4.0 application, but since the contents of it is viable to change, I was thinking using HTML to lay it out might be easiest. Is there a way to achieve this in windows forms? There are some other topics with C# and HTML but pretty sure non involves creating a control that parses HTML and displays it.
Thanks
You could use a WebBrowser, but I'd recommend not going down that path. Just use traditional controls to accomplish what you need, if at all possible, maybe combined with a little GDI+.
A WebBrowser would be your best bet in terms of ease of use and maintenance. You can have further control over the contents themselves by accessing the browser.Document.DomDocument interfaces and events. I would not recommend using GDI since it can become a pain to maintain and manage custom rendering in the long run.
I have been trying to do a similar thing and have found awesomium. They have a dotnet and mono wrapper and quite fine grain control over the whole thing acts. It is also free as long as your company makes less than 100k a year.
Forgot to mention it is a browser that you basically embed in your application so you don't need to worry about the user not having it installed or anything and is consistant over pc's and OS's

How To Create Cross Browser Asp.net Custom Control

I'm goingto create an asp.net control which should be cross browser. and support some skin - multilanguage and rtl & ltr support.
I want to know what should I consider and also looking for a good article
Write valid xhtml.
Read this article on How to make Cross Browser Websites. It doesn't really have to do with if you use asp.net or php to create re-usable web-controls / sites. You just need to follow the standards and maybe apply some hacks if you want to support older versions of web-browsers.
Have a look at this series: Building ASP.NET User and Server Controls
Cross browser designs generally depends on what kinda design features you want to support, best thing to get started with is learning asp.net control adapters, It's basically bunch of ready made samples that shows how to detect browser early in the execution of the request and reflect to the design using in-built actions provided by asp.net technology, or write your own!
Hope this helps

Categories

Resources