views:

220

answers:

1

I have the following controller:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcApplication1.Controllers
{
    public class TestController : Controller
    {
        public ActionResult Test()
        {
            return View();
        }

        public string AjaxTest()
        {
            return "Some random text";
        }

    }
}

I have the following View:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<html>
<head runat="server">
    <title>Test</title>
      <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>

    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
</head>
<body>
  <%= Ajax.ActionLink("Ajax Test", "AjaxTest", new AjaxOptions{UpdateTargetId="testtarget" }) %>
  <div id="testtarget">Test Div</div>
</body>
</html>

When I click the action link in IE the controller code runs but the div is NOT updated. Do it in ANY other browser and it works just fine. Is this (yet another) known problem/bug with IE?? Or am I doing something wrong?

A: 

You should add doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

Without it, you can have some problems, but still it works for me with it and without. Maybe there is some kind of caching problem? Ctrl + F5 and try again.

LukLed
I actually took that line out to avoid clutter im my post ;)I about it being a cache problem but refreshing the page and Ctrl-F5 doesn't fix it. Occasionally i can get it to work... once. But if i refresh the page and try again it doesn't update. There doesn't appear to be any pattern to it. If i then clear browser cache and refresh it still wont update. Im thinking it's got something to do with the MicrosoftMvcAjax.js script files that sit in behind it. But then how many hours in the day are we supposed to have? ;)
rism
@rism: I don't know what is the reason of the problem, but you could think about using jQuery. It is more popular and can be useful not only with ASP.NET MVC. You could write your own ActionLink using jQuery. That is what I did.
LukLed