views:

24

answers:

2

Hello all,

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" />                    
</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...

A: 

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.

Rohan Singh
thanks for your reply. the MicrosoftAjax.js has already been added to the file. We were using the scriptmanager to register a servicereference as explained above. we will have to figure out another way to do this.
rusty
AFAIK that's not possible. The ScriptManager is required to generate the service proxy, but it will take over the `sys` object and break `sys.mvc`.
Rohan Singh
A: 

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

rusty