Here is my partial view:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<script type="text/javascript">
function myFunction() { .... }
</script>
....other html content ...
On my page, I have a link that calls a controller action to render the partial view:
<%= Ajax.ActionLink(..., new AjaxOptions { ..., OnSuccess = "myFunction" }) %>
This is my controller action: ... return PartialView("TestControl"); ...
I thought that this is pretty straight forward. Unfortunately, I get the JavaScript error:
Microsoft JScript runtime error: 'myFunction' is undefined.
When I check the generated page source after the AJAX call, I can see myFunction
in the source. However, within AJAX's OnSuccess
, somehow it does not know about this function. Is there anything I have missed? Is there any way that I can call the script that are part of the partial view that is loaded via AJAX? (I have tried to use eval()
, somehow I could not resolve the function either.)
Thanks in advanced.