如何从代码隐藏调用 javascript 函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4847819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 14:23:30  来源:igfitidea点击:

How to call javascript function from code-behind

javascriptasp.net

提问by zanhtet

Possible Duplicate:
Calling javascript from code behind

可能的重复:
从后面的代码调用 javascript

I wrote a javascript function on asp.net page. This is that..

我在asp.net 页面上写了一个javascript 函数。这就是..

function Alert(){ alert('hello'); }
function Alert(){ alert('你好'); }

I want to call this function from code-behind view. How can I do.

我想从代码隐藏视图调用这个函数。我能怎么做。

回答by decyclone

You can use Page.RegisterStartupScript()to setup javascript code to be called on client side page load.

您可以使用Page.RegisterStartupScript()设置在客户端页面加载时调用的 javascript 代码。