开发者

Error with Ajax.Beginform on ASP.NET MVC Page

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.


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">
      </script>
      <script type="text/javascript"
              src="http://ajax.microsoft.com/ajax/mvc/1.0/MicrosoftMvcAjax.js">
      </script>
<% } %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜