1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Search Results

Custom Search Results

44 posts, 1 answered
  1. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jun 2010
    Link to this post
    Hello Laura,

    Where you use CustomSearchResultsClass.cs ? What is SearchResultsControlBase  and why you are crating a user control instead of custom control as all other samples shows this? You should use custom control that inherits from SearchResults. Using user control will not do the trick. The user control could be only a template of the custom control.


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  2. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    21 Jun 2010
    Link to this post
    Well, obviously, I am confused with it all. :(      All I need to do is access the search results items so that I can loop though the results list and print out to the page the results based on the user's role.  I am just trying to just get the first step done which is create a custom control / template to access the results.  All the examples are slightly different and it gets confusing when you don't know 100% what you are doing.  :((  I guess I went down the wrong path.  Could you please put a simple example of the template and code/toolboxitem?  I would appreciate it sooo much! thank you.
  3. mcpdinkansas
    mcpdinkansas avatar
    102 posts
    Registered:
    22 Mar 2007
    21 Jun 2010
    Link to this post
    Hey Laura,

    My post from Apr 12, 2010 should contain all necessary components to get the custom search working, minus any custom code you need.

    Keep in mind, no .ascx controls need to be registered in the web.config for this. By registering your class within web.config it should work.
  4. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    21 Jun 2010
    Link to this post
    Okay, so now to get down to the basics - I have a class SearchresultsCustom.cs in the App_Code/CS_Code/ folder with the following.
    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Telerik.Search.Engine;
    using Telerik.Search.Common;
    using Telerik.Utilities;
    using Telerik.Search.WebControls;
    using Telerik.Cms.Web.UI;
    using Telerik.Framework.Web;
    using Telerik.Search.WebControls.Admin;
    using Telerik.Framework.Web.Design;
      
    /// <summary>
    /// Summary description for SearchResultsCustom
    /// </summary>
    /// 
    public class ResultToolboxItemCustom : System.Drawing.Design.ToolboxItem
    {
        public ResultToolboxItemCustom()
            : base(typeof(SearchResultsCustom))
        {
            base.DisplayName = "CustomSearch";
            base.Description = "Custom Search Control";
        }
    }
      
    [System.ComponentModel.ToolboxItem(typeof(ResultToolboxItemCustom))]
    public class SearchResultsCustom : SearchResult
    {
        public SearchResultsCustom()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }

    And in the Web config I have the followng:
    <add name="SearchResultsCustom" section="Custom" type="SearchResultsCustom" />

    I don't have ,App_Code because I have the class in App_Code/CS_Code/

    And I get the error (see graphic) "Could not load type 'SearchReultCustom' from assembly 'Telerik.CMS, Version 3.7.2022.2 .....'"
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jun 2010
    Link to this post
    Hello Laura,

    The ToolboxItem should come from Telerik.Web not from System.Drawing. You should add App_Code to the type when you are registering the code no matter that you have a sub folder App_Code/CS_Code/.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    21 Jun 2010
    Link to this post
    Aurggg!   I am still getting the same error and I changed to Telerik.Web.ToolboxItem

    public
    class ResultToolboxItemCustom : Telerik.Web.ToolboxItem
    {
        public ResultToolboxItemCustom()
            : base(typeof(SearchResultsCustom))
        {
            base.DisplayName = "CustomSearch";
            base.Description = "Custom Search Control";
        }
    }
      
    [System.ComponentModel.ToolboxItem(typeof(ResultToolboxItemCustom))]
    public class SearchResultsCustom : SearchResult
    {
        public SearchResultsCustom()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }

  7. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    21 Jun 2010
    Link to this post
    and this goes in <toolboxControls> in the webconfig right?
    <add name="SearchResultsCustom" section="Custom" type="SearchResultsCustom, App_Code" />
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jun 2010
    Link to this post
    Hello Laura,

    I attached a sample project with custom SearchResults control that you can observer. The thread contains about 40 posts that explains how to create the custom control, so you could go through them once again.
    You can access the test project using admin as username and password. Database backup is attached to the zip.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    04 Jul 2010
    Link to this post
    Thank you. It had to do with how it was referenced in the App_Code folder and the CSCode folder as I had thought. Got it working ...  but now receiving error of :



    Value cannot be null.
    Parameter name: container

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.ArgumentNullException: Value cannot be null.
    Parameter name: container

    Source Error: 

    Line 39: 
    Line 40:         this.LayoutTemplatePath = "~/Custom/Controls/Search/SearchResult.ascx";
    Line 41: this.LayoutTemplate.InstantiateIn(this.container);

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Jul 2010
    Link to this post
    Hello Laura,

    The container you use is null. Make sure that you have defined container in your custom SearchResult control and create a new instance of it inside CreateChildControls method.

    protected override void CreateChildControls()
    {
        this.Controls.Clear();
     
        this.contianer = new Container(this);
        this.LayoutTemplate.InstantiateIn(contianer );
                      // other logic goes here
     
        Controls.Add(this.contianer );
     
    }
             protected Container contianer;

    You could expose the the container as a property which is the better option.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    18 Jul 2010
    Link to this post
    Thank you Ivan for your patience with me on this. And thank you to Pik for the code sugestion.  Finally got it to work as we wanted.  Thanks again.

    One last question....

    Instead of having the search box as an object to drop onto a page, how can I put it directly in the master page?  I know how to do this with controls, but not with classes.  I am uisng VB in my master page.  Is this possible?

    Thank you!
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    18 Jul 2010
    Link to this post
    Hi Laura,

    You can drop the control on your template through Sitefinity UI >> Pages >> Templates, otherwise the control will be hardcoded in your master page and you will not be able to edit it through Sitefinity. You can register the control in the master page ile using Register directive

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    19 Jul 2010
    Link to this post
    Thank you.  I wanted to avoid dropping it on the many templates I have.  But anyway - when I do that it forces me to log in to the SSO session we connect to!

    I set the additional catalog  as such below.  This role is tied to a single sign on.
    /If user is logged in set the appropriate catalog.
    if (HttpContext.Current.User.IsInRole("MEMBER") == true)
    }
    AdditionalCatalogName =
    "MemberOnly";
    }
    Should I add somethig like If Request.QueryString("cmspagemode") and how do I do that from within the class file?
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Jul 2010
    Link to this post
    Hello Laura,

    Most probably your authentication cookie has been cleared or it is not in the cookies collection. Also, Search index can work only in the context of Sitefinity application.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
44 posts, 1 answered
1 2