views:

189

answers:

1

Hi

I am using Ajaxy Call to load the partial view. It is working fine in Firefox and IE without in Debug Mode. But in Debug mode, I am getting the follwoing error:

Error: 'Sys' is undefined

Ajaxy call Code:

 <% using (Ajax.BeginForm("SearchResults", new AjaxOptions { UpdateTargetId = "divLoadSearchResults" } ))
{%>

HTML View Source corresponding to this:

<form action="/Home/SearchResults" method="post" onclick="***Sys.***Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'divLoadSearchResults' });">

I am using MVC RC2 framework. Anyone have similar problems with RC2?

If it is not in Debug mode, it is working fine. Again, if i run it using Debug mode or CTRL+F5, it shows up the error.

Appreciate your responses.

+1  A: 

Sounds like it is not loading the MicrosoftMvcAjax.js or MicrosoftAjax.js files when in debug mode. Check where you are including these files and make sure that there aren't any conditionals that would exclude it. If you are using the content delivery network to load it when not debugging, make sure that the paths in the alternate loads when debugging are correct.

Ex:

<% if (debug) { %>
     <script type="text/javascript"
             src="<%= Url.Content( "~/scripts/MicrosoftAjax.debug.js" ) %>">
      </script>
      <script type="text/javascript"
              src="<%= Url.Content( "~/scripts/MicrosoftMvcAjax.debug.js" ) %>">
      </script>
<% }
   else { %>
      <script type="text/javascript"
              src="http://ajax.microsoft.com/ajax/mvc/1.0/MicrosoftAjax.js"&gt;
      </script>
      <script type="text/javascript"
              src="http://ajax.microsoft.com/ajax/mvc/1.0/MicrosoftMvcAjax.js"&gt;
      </script>
<% } %>
tvanfosson
That's correct. It worked. +1 and accepted.
Rita