[英]Javascript call from C# not working when use RenderControl
I am following this article. 我正在关注这篇文章。 http://www.codeproject.com/Articles/23768/Load-and-Display-Page-Contents-Asynchronously-with
http://www.codeproject.com/Articles/23768/Load-and-Display-Page-Contents-Asynchronously-with
I have a usercontrol with some javascript codes. 我有一些JavaScript代码的用户控件。 Lets say there is a method called alertMe(msg) in javascript.
可以说javascript中有一种称为alertMe(msg)的方法。 And i am calling this from c#.
我是从C#调用的。 It is not calling.
它没有打电话。 i am using this.page.clientscript.registerscriptblock function.
我正在使用this.page.clientscript.registerscriptblock函数。
Even the javascript is not rendered in the page. 即使JavaScript也不在页面中呈现。 I did check it by pressing F12 in chrome browser and went to console and typed the method name, it said undefined.
我确实通过在chrome浏览器中按F12进行了检查,并转到控制台并键入了方法名称,它表示未定义。
Have you tried ScriptManager instead of Page.ClientScript? 您是否尝试使用ScriptManager而不是Page.ClientScript? I think that the script is not available during a partial postback if it is not registered with the ScriptManager.
我认为,如果未向ScriptManager注册,则脚本在部分回发期间将不可用。
Looks like this: 看起来像这样:
ScriptManager.RegisterStartupScript(Page, this.GetType(), "DatePickerScript" clientScript, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.