I'd like to override Content Search Web Part (SharePoint 2013) and I found following articles on this subject

However, problem is I'm not quite sure how it could be done. I've created Empty SharePoint Project and added both class to it (.cs file) and references Microsoft.Office.Server.Search and System.Web.UI.WebControls.WebParts (and, of course, reference them to the file by key word using). However, I can't expose class ContentBySearchWebPart (to override it).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server.Search;

namespace SharePointProject

    public class CustomCSWP : ContentBySearchWebPart

ContentBySearchWebPart has red underline with Error Message - "The type or namespace name 'ContentBySearchWebPart' could not be found (are you missing a using directive or an assembly reference?)

EDIT: Solution is made as farm solution.


Trick is to add reference to Microsot.Office.Server.Search.WebControls. However, "Add Reference..." window didn't expose this dll, so I had to manualy add it from GAC (C:\windows\Windows.NET\assembly\GAC_MSIL\Microsoft.Office.Server.Search).

| improve this answer | |

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.