如何从javascript或jqury调用C#函数后面的代码 [英] How to call code behind C# function from javascript or jqury

查看:67
本文介绍了如何从javascript或jqury调用C#函数后面的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的解决方案中有两个项目:演示和CommonControls。



我需要调用CommonControls中的类中定义的函数。但是这个调用必须来自Presentation中定义的javascript函数,它是Presentation项目的常见js文件。



如何实现这一目标?



提前谢谢。

Hi all,

I have two projects in my solution : Presentation and CommonControls.

I need to call a function defined in a class inside CommonControls. But this call has to be from the javascript function defined in Presentation which is a common js file for Presentation project.

How do I achieve this?

Thanks in advance.

推荐答案

你永远不会从JavaScript调用代码隐藏函数。 代码隐藏是由服务器端的HTTP服务器执行的,并且客户端的浏览器调用JavaScript。您可以触发一些代码隐藏代码并仅使用Ajax获得一些响应。请从这里开始:

http://en.wikipedia.org/wiki/Ajax_% 28programming%29 [ ^ ],

http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/ [ ^ ],

http://ajaxcontroltoolkit.codeplex.com/ [ ^ ],

http://www.ajaxtoolkit.net/ [ ^ ],

http://api.jquery.com/jQuery.ajax/ [ ^ ]。



祝你好运,

-SA
You never ever call a code-behind function from JavaScript. "Code behind" is something executed by the HTTP server, on server side, and JavaScript is called by the browser, on the client side. You can trigger some code-behind code and get some response only using Ajax. Please start here:
http://en.wikipedia.org/wiki/Ajax_%28programming%29[^],
http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/[^],
http://ajaxcontroltoolkit.codeplex.com/[^],
http://www.ajaxtoolkit.net/[^],
http://api.jquery.com/jQuery.ajax/[^].

Good luck,
—SA


这篇关于如何从javascript或jqury调用C#函数后面的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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