Haiyuan Zhang
Haiyuan Zhang

Reputation: 42792

Is it possible to embeded js into c#

Currently I'm involved in a project using c# . I know some of the features of this project can be easily implemented using Javascript (I have been a js developer for some time, but totally new to c#). so I'm very eager to know if it is possible to reuse the available js code in the project, or put it another way, embeded js into c# .

thanks in advance.

Upvotes: 1

Views: 258

Answers (6)

serg10
serg10

Reputation: 32667

I think you're asking if it is possible to run JavaScript on the CLR. Similar to Java 6's JVM script engine.

EcmaScript.net could be your best bet - http://code.google.com/p/ecmascript-net/ - see also this question - Are there any .NET CLR/DLR implementations of ECMAScript?

Upvotes: 4

t0mm13b
t0mm13b

Reputation: 34592

There is an extensive article written on how to embed Javascript within C# here. Is that what you are looking for?

Upvotes: 3

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65391

Javascript runs in the browser, as long as it is a web project there is no problblem combining. C# code will run on the server, javascript code in the browser.

http://msdn.microsoft.com/en-us/library/aa479011.aspx

Upvotes: 0

Konrad Rudolph
Konrad Rudolph

Reputation: 545588

The way you write it it sounds like a giant cop-out of learning C# properly. Unless you actually mean that you want to use JavaScript for client-side control of your project, this is a no-go (and it doesn’t sounds like you meant client-side scripting).

That said, .NET actually allows you to mix assemblies from different languages effortlessly, but this only applies to .NET languages which can be compiled to .NET IL (bytecode) and I’m not aware of a JS-to-IL-compiler.

Upvotes: 0

Mark Redman
Mark Redman

Reputation: 24515

There is no reason you cant continue to use existing client side javascript code. There is a still a clear distinction to whats required on the client and what can be called by the client.

Various possibilities include: calling web services, making ajax calls to WebMethods and injecting javascript code into pages.

Upvotes: 0

Adriaan Stander
Adriaan Stander

Reputation: 166396

Are you referring to ClientScriptManager RegisterClientScriptBlock Method

Upvotes: 0

Related Questions