How to get a custom search going...

Posted by Community Admin on 05-Aug-2018 04:53

How to get a custom search going...

All Replies

Posted by Community Admin on 23-Jan-2011 00:00

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?

Posted by Community Admin on 25-Jan-2011 00:00

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 http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/search-widget-appearance.aspx

Greetings,
Ivan Pelovski
the Telerik team

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

This thread is closed