[英]ReferenceError: function is not defined on the onclick function
I get a "ReferenceError: punt is not defined" - everything seems to be right and I can't identify the mistake. 我收到“ ReferenceError:未定义平底锅”的提示-一切似乎都正确,我无法识别错误。
Here is the related code: 以下是相关代码:
<script src="../Scripts/jquery-1.9.1.min.js" type="text/javascript">
function punt(rowIndex, Name, actionType) {
alert("hello");
}
</script>
and inside the ItemTemplate in the Repeater I have: 在Repeater的ItemTemplate中,我有:
<input type="image" style="border-width:0" src='<%=ResolveUrl("~/css/images/icon_update.png") %>'
alt="Update Reviewer List" tabindex="0" title="Update Reviewer List"
onclick="punt(<%#Container.ItemIndex%>,
'<%#HttpUtility.HtmlEncode((string)DataBinder.Eval(Container.DataItem, "Name"))%>',
'Update');
return false;" />
You can't combine a script include and inline javascript. 您无法将脚本包含和内联JavaScript结合使用。
<script src="../Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
<script>
function punt(rowIndex, Name, actionType) {
alert("hello");
}
</script>
Your script tag which includes the external script should be separate from your script tag where you define your new function, ie: 包含外部脚本的脚本标签应与定义新功能的脚本标签分开,即:
<!-- first script tag -->
<script src="jquery"></script>
<!-- second script tag -->
<script>
// punt function
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.