I'm using the content by search webpart. I would like it to display a message when there is no matches, seems simple right? I've pulled my hair out trying to figure this out, and i'd appreciate an assist.

In the display template there these two lines of code, that suggest they have something to do with displaying the no results message, however changing these lines and $noResults variable in the display template seems to have no effect.

var $noResults = Srch.ContentBySearch.getControlTemplateEncodedNoResultsMessage(ctx.ClientControl);


if (ctx.ClientControl.get_shouldShowNoResultMessage())
,'        <div class="', noResultsClassName ,'">', $noResults ,'</div>'

My question is how do you set the default empty text with the content by search webpart the right way?


In Addition to what Vassili mentioned below you also will need to uncheck the Don't show anything when there are no results. checkbox in the visible web-part properties. I often wonder why Microsoft has to make something so seemingly simple so confusing!

1 Answer 1


You'll need to set the EmptyMessage web part property value. The property is hidden so you'll have to set it programmatically or by exporting the web part and editing the .webpart file.

  • 1
    Firstly thanks for sharing this solution. I made the changes and I am now getting a message when there are no results but it's not what I entered into the empty text. I get a message "There are no items to show". Any ideas?
    – user38651
    Jan 14, 2015 at 7:21
  • Which display template is the web part configured to use? Is it out-of-the-box template or custom? Jan 16, 2015 at 23:34
  • I don't know if someone has managed to make it work with EmptyMessage Webpart property, but for me it doesn't work. I had to customize the $noResults variable in the control template. Otherwise I would get stuck with "There are no items to show. ". Jul 25, 2015 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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