Implementing Share Point Search functionality in a Visual Web Part RRS feed

  • Question

  • Hi,

    I am using share point on-premise. I created a visual web part which contains a textbox. Here i want to integrate the share point search functionality. can you please help me in this regards ?

    Thank You,


    Thursday, August 1, 2019 7:20 AM

All replies

  • Hi,

    You could build search by keywordquery class.

    KeywordQuery keywordQuery = new KeywordQuery(siteCollection);
    keywordQuery.QueryText = "SharePoint";
    SearchExecutor searchExecutor = new SearchExecutor();
    ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
    var resultTables = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults);
    var resultTable = resultTables.FirstOrDefault();
    DataTable dataTable = resultTable.Table;

    Here is one thread for your reference.

    Best Regards,


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, August 2, 2019 1:28 AM