.JS javascript文件中的C#代码 [英] C# code from .JS javascript file

查看:78
本文介绍了.JS javascript文件中的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以从.js文件中编写C#代码?

谢谢

There is any way at all to write a c# code from .js file?

Thank you

推荐答案

您不能用Java脚本编写C#并执行它.

天哪,您能想象如果我可以将C#作为字符串传递并自动执行,该怎么办?

但是,您当然可以通过创建PageMethod或Web服务来通过其字符串键从会话中删除对象,从而从服务器端会话中删除对象.

Dave Ward @ Encosia在这里进行了广泛讨论. [ ^ ]


如今,这确实很容易,并且随着您的使用变得更容易(实际上,如果您使用的是MVC,这确实有点容易,谢谢),并且真的有必要在将来寻求进一步的使用.客户端交互.
You can''t write C# from Javascript and have it be executed.

My god, could you imagine the HAVOC I could do if I could pass C# as a string and have it automatically execute?

However, you can certainly remove an object from Server-side session by creating a PageMethod or web-service that removes an object from session by it''s string key.

Dave Ward @ Encosia talks about it extensively here.[^]


It''s pretty darn easy nowadays, and gets easier as you do it (in fact, it''s really a tad easier thank this if you''re using MVC) and really warrants looking at for further use down the road for client-interaction.


如何从jQuery函数中调用c#函数
使用<%=代码%>嵌入C#代码在javascript< script>中标签
在MVC框架的Javascript文件中使用内联C#
How to call c# function from the jQuery function
How to call c# function from the jQuery function
Embedding C# code using <%= code %> within javascript <script> tags
Using Inline C# inside Javascript File in MVC Framework


这篇关于.JS javascript文件中的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆