Execute JavaScript function in C # application

Without using the WebBrowser control, how can I execute a JavaScript function that is separated from any browser DOM dependencies in a C # application? I examine the rules of validation only once, both for server verification and for the client. See this question for reference if you want. Are there any JS interpreter libraries that I could use?

Application: My goal here is to automatically deploy and invoke exactly the same validation logic on the client and server, without communication between them during the actual verification. Therefore, ideally, I would encode my validation logic in JavaScript and display it on the page. Alternatively, I could encode my logic in C #, convert it to JavaScript using Script #, and display this on the page.

I don’t want individual validation functions to be supported on the client and server side, and I don’t want AJAX to call server validation functions, and I don’t want the validation only on the client or server basis.

+5
source share
4 answers

A script #/VB.NET/JScript.NET, Framework script VB, # JavaScript.

CodeDomProvider , .

+2

Windows Script Host (WSH) - Windows. PInvoke #. ( ) JavaScript MS.

WSH creates an environment for hosting scripts. That is, when Script arrives on your computer, WSH acts as a host - it makes objects and services available to Script and provides a set of manuals in which Script is run. Among other things, the Windows Script Host manages security and invokes the appropriate Script engine.

0
source

Try pinvoke spider monkey - http://www.mozilla.org/js/spidermonkey/

0
source

All Articles