How to remove “No results are available. Either no query is specified, or the query came from advanced search (Federated Webparts do not support Advanced Search queries)” when no search keywords are specified

The OOTB Search Core Results web part will show the message below when no search keywords are specified (i.e. no k=blah in the queryString):

No results are available. Either no query is specified, or the query came from advanced search (Federated Webparts do not support Advanced Search queries).

The result display of this web part is driven by XSL, and it would seem that one can turn off this message by tweaking the XSL. But try it and you’ll find that it won’t work. (If you can get it to work let me know!)

You can hide this message with a somewhat no-code solution by adding a Content Editor web part to the page and some JQuery. See this link: As the JQuery needs the ID of the web part however, this is not a very reusable solution.

For a coded (and reusable solution) you will need to extend the OOTB CoreResultsWebPart. The code is very simple. Create a Web Part (not a Visual Web Part), then inherit from CoreResultsWebPart. You will need to add a reference to Microsoft.Office.Server.Search.dll to the project. Enter the code below for your web part class:

/// <summary>
    /// The OOTB web part displays an error message when no search keywords are specified. This inherited web part hides itself (hence the error message)
    /// when it is in Display mode and no keywords are specified.
    /// </summary>
    public class MyCoreResultsWebPart : CoreResultsWebPart
		protected override void OnLoad(EventArgs e)

			base.Hidden = (base.QueryInfo == null) && !this.IsInEditMode;

        private bool IsInEditMode
            get { return (base.WebPartManager != null && !base.IsStandalone) && base.WebPartManager.DisplayMode.AllowPageDesign; }

Also, enter these properties in the .webpart file for your web part:

				<property name="Title" type="string">My Search Core Results</property>
				<property name="Description" type="string">Use to display search results</property>
				<property name="ChromeType" type="chrometype">None</property>
				<property name="ShowActionLinks" type="bool">false</property>
				<property name="ExportMode" typ="exportmode">All</property>

These properties are not mandatory, but they will replicate some of the key behaviours of the OOTB web part for our custom one.

That’s it. Go ahead and deploy your solution.


About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Search, SharePoint 2010, WebPart. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s