Try Now
More in this section

Forums / Sitefinity SDK / How to get a custom search going...

How to get a custom search going...

2 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    03 Dec 2008
    23 Jan 2011
    Link to this post
    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?
  2. Ivan Pelovski
    Ivan Pelovski avatar
    43 posts
    24 Sep 2012
    25 Jan 2011
    Link to this post
    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

    Ivan Pelovski
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered