如何从javascript中的代码调用方法 [英] how to call a method from code behind in javascript

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

问题描述





请让我知道如何从java脚本中调用代码中的方法。



Please let me know how can i call a method in the code behind from the java script.

推荐答案

如何从javascript中的代码调用方法 [ ^ ]


检查谷歌 [ ^ ]。


你不能。 JavaScript在客户端工作,因此没有调用它。使用谷歌,你会发现很多问题的解决方案,但你应该明白,他们不会调用任何脚本功能,实际上有助于创建他们并确保他们叫。加载页面时执行的一种方便的方法是使用 ScriptManager.RegisterStartupScript

使用ScriptManager.RegisterStartupScript从代码调用javascript函数 [ ^ ]。



您可以创建处理各种事件的脚本。无论你做什么,整个页面都在服务器端生成,并在客户端完全加载并在浏览器中调用。在下一个HTTP请求(包括回发)之前,客户端和服务器端甚至都没有通信。



-SA
You cannot. JavaScript works on the client side, so there are no "calls" to it. Using Google, you will find many solutions of the problem, but you should understand that they don't "call" any script functions, the actually help to create them and make sure they are called. One convenient method of doing when the page is loaded so is using ScriptManager.RegisterStartupScript:
Call to javascript Function from code behind using ScriptManager.RegisterStartupScript[^].

You can create scripts handling various events. No matter what you do, the whole page is generated on the server side and fully loaded on the client side and called in the browser. Before next HTTP request (including postbacks), client and server sides do not even communicate.

—SA

这篇关于如何从javascript中的代码调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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