开发者

MVC 3 Razor Ajax BUGs

ajax link is:

@Ajax.ActionLink("AjaxLink","GetText","Home", new AjaxOptions{UpdateTargetId = "ajaxDiv", HttpMethod = "Get"})

<div id="ajaxDiv"></div>

Controller:

    [HttpGet]
    public ActionResult GetText()
    {
        return View();
    }

View: GetText.cshtml:

<div>Some text @DateTime.Now.ToLongTimeString()</div>

ok, it work. But, if I clik on link over and over again, Page slows down. Th开发者_运维知识库e more time I clicked on, the longer time on page hangs. I used the debug:

And it turned out that after the first click, the function GetText () is called once, after the second click, the function is called twice, after the third - three, and so on. In what may be the problem?


You should be returning a PartialView instead of a full view so that it returns only the HTML snippet you want without including the master view. I suspect that the handler is getting re-applied via the master, but there's not really enough information in your question to be sure.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜