How much work is involved adding AJAX section in an existing MVC3 app?

孤人 提交于 2019-12-13 05:38:02

问题


I have an application where it search images that are stored in the database and displays the result (with pagination). Currently every time the next page is loaded our whole site is reloaded. Hence, our site is noticeably sluggish.

I was looking into iStockPhoto and see that only the images content is loaded and their performance is much better than mine.

I am using Solr (which to me seems slow.. anything I'm missing? I thought Solr is supposed to be quick. Haha) to store and retrieve images.

SO !!

my question to you gents/ladies is if I want to allow only the pagination contents to be refreshed when next page is hit, is there a lot that I have to do? Such as changing Controllers, Views, and etc.?

Thank you so much!

This is the code I have:

<table>
<tr>
    <td>...</td> 
    <td valign="top" style="width: 100%">
        <div id="imageList" class="imageList">
            @Html.Partial("AssetManagerSelection", new FacetsWidget
                                        {
                                            SelectedFacetNodes = Model.Search.SelectedFacetNodes
                                        })
            @{
                var pagerInfo = new PaginationInfo
                {
                    PageUrl = Url.SetParameter("page", "!0"),
                    CurrentPage = Model.Search.PageIndex,
                    PageSize = Model.Search.PageSize,
                    TotalItemCount = Model.TotalCount,
                };
            }      
            @Html.Partial("AssetManagerPager", pagerInfo)
            @if (pagerInfo.CurrentPage <= pagerInfo.LastPage)
            {
                <ul class="thumbnailsList">
                    @{var thumbnailIndex = 1;}
                    @foreach (var item in Model.MatchingItems)
                    {
                        var thumbnailClass = string.Empty;
                        if (Model.Search.ThumbnailSize == CacheLevel.DetailsView)
                        {
                            thumbnailClass = "thumbnailImagesS";
                        }
                        else
                        {
                            thumbnailClass = "thumbnailImagesM";
                        }
                        <li>
                            <div class="@thumbnailClass">
                                @Html.Partial("ItemThumbnail", item)
                            </div>
                            @{thumbnailIndex++;}
                        </li>
                    }
                </ul>
                @Html.Partial("AssetManagerPager", pagerInfo)
            }
        </div>
    </td>
</tr>

来源:https://stackoverflow.com/questions/8838052/how-much-work-is-involved-adding-ajax-section-in-an-existing-mvc3-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!