从后面的代码调用javascript函数不起作用。 [英] Calling javascript function from code behind is not working.
问题描述
我试图在按钮点击时调用javascript函数。按钮点击数据绑定到gridview,然后调用此函数。
我试图调用函数如下:
I am trying to call a javascript function on button click. On button click data binds to gridview and then this function is called.
I am trying to call function like:
ClientScript.RegisterClientScriptBlock(this.GetType(), "tmp", "CreateClickableLinks();", true);
并且函数存在于aspx文件中。
And function is present in aspx file.
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/Validation.js"> </script>
<script type="text/javascript" src="../Scripts/progress.js"></script>
<script type="text/javascript">
function CreateClickableLinks() {
alert($("#<%=gvOpenProblems.ClientID %>").html());
}
</script>
当我运行代码时,我得到错误的对象预期:CreateClickableLinks
我调用函数的方式有什么问题或函数本身有问题吗?
When I run code I get error as Object expected : CreateClickableLinks
Is there anything wrong in the way I call function or there is something wrong with function itself?
推荐答案
(#<%= gvOpenProblems.ClientID%>)。html());
}
< / script>
("#<%=gvOpenProblems.ClientID %>").html()); } </script>
当我运行代码时,我得到错误的对象预期:CreateClickableLinks
我调用函数的方式有什么问题或函数本身有问题吗?
When I run code I get error as Object expected : CreateClickableLinks
Is there anything wrong in the way I call function or there is something wrong with function itself?
RegisterClientScriptBlock [ ^ ]方法将脚本块添加到呈现页面的顶部。可能是在进行调用时尚未添加定义。
请尝试: ClientScriptManager.RegisterStartupScript Method [ ^ ]
看看是否有帮助。
The RegisterClientScriptBlock[^] method adds a script block to the top of the rendered page. It might be that when the call is made the definition is not yet added.
Instead try: ClientScriptManager.RegisterStartupScript Method[^]
See if it helps.
hi
ClientScript.RegisterClientScriptBlock(this.GetType( ),tmp,alert(
hi
ClientScript.RegisterClientScriptBlock(this.GetType(), "tmp", "alert(
这篇关于从后面的代码调用javascript函数不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!