Skip to main content


Quick custom Search Results web part

To create a search results web part that will dynamically create a search query and render the search results is pretty easy.

Create a new web part and inherit the CoreResultsWebPart.

public class MySearchWebPart: CoreResultsWebPart
     public MySearchWebPart(): base()
          // Initialize the search results web part here…
         //e.g this.ResultsPerPage = 10;
         //Set the Fixed Query here.
         this.FixedQuery = “Some Query”; // Build query based on some criteria. Either from Page Fields, keywords, etc.

.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode, .ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode pre
{font-size:small;color:black;font-family:consolas, "Courier New", courier, monospace;background-color:#ffffff;}
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode pre
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .rem
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .kwrd
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .str
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .op
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .preproc
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .asp
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .html
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .attr
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .alt
.ExternalClassD5F93078116B4883B34A7A2CB705C28A .csharpcode .lnum

That’s it. This will give you fresh content based on the query that is built at runtime.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Amol Ajgaonkar

More from this Author

Follow Us