We have a simple ajax link (Ajax.ActionLink(...)) that has been working fine. Recently, another developer added some ajax-ey code to the same page that uses an asp scriptmanager ... now suddenly the first ajax link no longer works. More specifically we get the error : "sys.mvc.asynchyperlink' is null or not an object". Below is a sample :
<a id="linkID"
href="someURL"
onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace });">
<img src="linkImage.jpg" />
&开发者_开发技巧lt;/a>
....
<asp:ScriptManager ID="_someID" EnablePartialRendering="true" ScriptMode="Release" runat="server">
...
</asp:ScriptManager>
What is the relationship between these two? Can they coexist?
EDIT : so, it turns out we are using the scriptmanager to register a ServiceReference to hook into a web service we've set up. The scriptmanager makes the service available from our javascript functions. Is it possible to get the ServiceReference registered/added without using the scriptmanager? This is perhaps a completely different question...
The ScriptManager control is not built to coexist with ASP.NET MVC. Just remove it and replace it with the following:
<script src="MicrosoftAjax.js"><script>
Note that the path will vary based on where MicrosoftAjax.js is in your project, but it should be in the Static/js folder in any new ASP.NET MVC project.
For the record, we ended up getting around using the Scriptmanager for the service reference by using a web service proxy, as outlined in this tutorial by Stephen Walther http://stephenwalther.com/blog/archive/2008/03/14/using-asp-net-ajax-with-asp-net-mvc.aspx
精彩评论