How to get a custom search going... - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How to get a custom search going...

  • How to get a custom search going...
  • I want the existing search control (has the designer, etc)...

    But I want it to have a RadTextBox instead of just a plain input

    How do I go about that with the templates?
    Hello Steve,

    Unfortunately you cannot change the template from Design -> Widget Templates page because there is custom logic depending on the controls used in it. You will have to inherit the SearchBox class itself and add new logic to it. What you will need is:
    • Override the LayoutTemplateName property to return null
    • Override the LayoutTemplatePath property to return the location of your template
    • Make the old TextBox control in the template not visible
    • Override the InitializeControls() method and initialize your RadTextBox control
    • Override the Query property although it is not virtual
    • Override the GetScriptDescriptors() method in order to include the component id of the RadTextBox control
    • Override the GetScriptReferences() method in order to reference a new script file
    • Inherit the class declared in "Telerik.Sitefinity.Services.Search.Web.UI.Scripts.SearchBox.js" file in order to make use of the RadTextBox cliet API.
    • Mark your new class with the needed attributes PropertyEditorTitleAttribute and ControlDesignerAttribute
    • Add your widget to the Toolboxes configuration.
    A code sample is also attached. Put the ascx file in /App_Data/CustomControlTemplates/ folder and the js file in the base directory of the site. If you place the files somewhere else then make the corresponding changes to the paths in the code (the layoutTemplatePath and searchBoxScript constants). You can also see this thread in the forum

    Ivan Pelovski
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.