[英]call javascript function from code behind C# web application
i have a javascript function say 'onclientclicking'. 我有一个JavaScript函数,说“ onclientclicking”。
<script type="text/javascript">
function OnClientClicking(button, args) {
window.location = button.get_navigateUrl();
args.set_cancel(true);
}
</script>
I want to execute this function from code behind. 我想从后面的代码执行此功能。 What i am trying to do is based on certain conditions, i need to set the event to telerik button
我想做的是基于某些条件,我需要将事件设置为telerik button
rad_btn_text.Attributes["OnClientClicking"] = javascript function;
how can it be possible? 怎么可能呢?
regards, 问候,
Sivajith S 西瓦吉斯(Sivajith S)
please try this: 请尝试以下操作:
rad_btn_text.OnClientClicking = "OnClientClicking";
It's working on my machine™ 在我的机器上运行™
You can't "call" client side javascript from the server. 您无法从服务器“调用”客户端javascript。 That said, you can wire up client side events and emit client side code.
也就是说,您可以连接客户端事件并发出客户端代码。
I don't use telrik controls but the asp.net property is onclientclick. 我不使用telrik控件,但是asp.net属性是onclientclick。 Not sure if that is the same on a telerik control and the client side event is onclick.
不确定在telerik控件上是否相同,以及客户端事件是否为onclick。
To call the javascript function from server side: 从服务器端调用javascript函数:
ScriptManager.RegisterStartupScript(this, typeof(Page), "OnClientClicking", "OnClientClicking();", True);
References 参考文献
rad_btn_text.Attributes.Add("onclick", "OnClientClicking()")
希望这对你有用
try this. 尝试这个。 when user click on button the function of "OnClientClicking" will be executed :
当用户单击按钮时,将执行“ OnClientClicking”功能:
rad_btn_text.Attributes["onclick"] = "OnClientClicking()";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.