页面加载后,局部呈现 [英] Partial rendering after page loaded

查看:136
本文介绍了页面加载后,局部呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些用户控件的页面。我想回发就像一个Ajax渲染后加载这些用户控件。

I have a page that contains some usercontrols. I would like to load these usercontrols after postback like an ajax rendering.

每个用户控件显示来自数据库的清单,我不希望用户等待服务器code建立起来,我认为这将是有用的,如果显示的页面为用户和用户控件后,通过加载响应Ajax请求。

Each usercontrols display a list from database and I dont want the user to wait while server code builds up the response I think it will be useful if the page is displayed for the user and after the usercontrols are loaded through an ajax request.

有没有在ASP.NET MVC的存在解决方案吗?是否有这一问题的存在解决办法?

Is there an exist solution in ASP.NET MVC? Is there an exist solution for this problem?

由于事先:→

推荐答案

我通常是这样的:

在标记我预留空间,为用户控制,应像

In the markup I reserve space for the user control to be loaded like

<div id="i-tabs-5">
    <div style="text-align:right;margin-bottom:6px;">...</div>
    <div id="issueNoteListPlaceholder"></div>
</div>

然后在DOM准备好我做一个AJAX调用返回的局部视图的结果,替换占位符的内容

then on DOM Ready I make an ajax call that return a partial view result and replace the content of the placeholder

$(document).ready(function () {
    loadIssueNotes();
});

function loadIssueNotes() {
    $.ajax({
        type: "get",
        dataType: "html",
        url: '<%: Url.Content("~/Controller/Action") %>',
        data: {},
        success: function (response) {
            $("#issueNoteListPlaceholder").html('').html(response);
        }
    });
}

这篇关于页面加载后,局部呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆