admin管理员组文章数量:1399242
I use below code for call javascript's function from code behind but doesn't call function
//C#
Page.ClientScript.RegisterStartupScript(this.GetType(), "close panel", "CloseFunction()", true);
//javascript
function CloseFunction() {
alert("call");
}
I use below code for call javascript's function from code behind but doesn't call function
//C#
Page.ClientScript.RegisterStartupScript(this.GetType(), "close panel", "CloseFunction()", true);
//javascript
function CloseFunction() {
alert("call");
}
Share
Improve this question
edited Apr 1, 2013 at 19:56
asked Apr 1, 2013 at 19:45
user1729807user1729807
3 Answers
Reset to default 3It should be true.
Page.ClientScript.RegisterStartupScript(this.GetType(), "close panel", "CloseFunction()",
true);
Update Link:
ClientScriptManager.RegisterStartupScript Method
a Boolean value indicating whether to add script tags.
Your last parameter on the C# code should be true
, not false
. This will add the <script>
tag around the script, which will execute it. Otherwise, it just prints the text out to the page.
Do not know about other answers, I tried all but didn't worked for me.
If anyone who is not able to do with those than try this :
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "MyJavascriptFunction();", true);
Ref. this suresh sir Link
本文标签: aspnetCall javascript39s function from code behindStack Overflow
版权声明:本文标题:asp.net - Call javascript's function from code behind - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744157318a2593168.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论