3

I have created the sharepoint 2013 content search web part. it shows only maximum of 50 results , i need to extent the count upto 200. is possible to do it in extended content search web part without pagination.if yes, suggest some idea to do it.

0

Create new web part in VS. Using reflection override max value to 200. After deployment in catalogs, you can insert that new webpart with override in page. Before saving webpart, you need put number from 1-50 (in properties for number items to show where says 200 you put 1-50)

using System;
using System.Reflection;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.WebControls;

namespace NamespaceName.CSWP200ItemsOnPage
{
    [ToolboxItemAttribute(false)]
    public class CSWP200ItemsOnPage : ContentBySearchWebPart
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            int maxValue = 200; //default is 50
            ResultScriptWebPart obj = (ResultScriptWebPart)this;
            Type objType = typeof(ResultScriptWebPart);
            FieldInfo fieldInfo = objType.GetField("resultsPerPage",
                BindingFlags.NonPublic | BindingFlags.Instance);
            if (fieldInfo != null)
            {
                fieldInfo.SetValue(obj, maxValue);
            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.