1

I get a "ReferenceError: punt is not defined" - everything seems to be right and I can't identify the mistake.

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:

<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;" />  
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Utpal Mattoo
  • 890
  • 3
  • 17
  • 41

2 Answers2

7

You can't combine a script include and inline javascript.

<script src="../Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
<script>
    function punt(rowIndex, Name, actionType) {
        alert("hello");
    }
</script>
Kevin B
  • 94,570
  • 16
  • 163
  • 180
  • http://stackoverflow.com/questions/1056325/javascript-inline-script-with-src-attribute The docs quoted state that the src takes precedence over the body of the tag, so punt() really isn't defined in the OP code. As such, they'll need to use modified code like yours. – BrianH Mar 27 '13 at 19:37
0

Your script tag which includes the external script should be separate from your script tag where you define your new function, i.e.:

<!-- first script tag -->
<script src="jquery"></script>

<!-- second script tag -->
<script>
 // punt function
</script>
Brian FitzGerald
  • 3,041
  • 3
  • 28
  • 38