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

Forums / Developing with Sitefinity / Indexcatalogue Picker

Indexcatalogue Picker

4 posts, 0 answered
  1. Josh
    Josh avatar
    19 posts
    Registered:
    24 Jun 2009
    05 Aug 2009
    Link to this post
    Guys, i have created a custom control that contains search functionality.  I have exposed the SearchResultsURL and the IndexCatalogue properties so the user can modify these when placed in a page.  Can someone show me the appropriate way to implement the web editor for the index catalogue drop down list?

    It is greatly appreciated!  Thanks!
  2. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    11 Aug 2009
    Link to this post
    Hello Josh,

    You could use "Telerik.Search.WebControls.IndexingServicesPicker, Telerik.Search" directly.

    Otherwise, you could "launch" a window with a IWebUITypeEditor (preferably, WebUITypeEditor<T>) with the following code snippet:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using Telerik.Cms.Web.UI; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    namespace Telerik.Help.Tools.MamlExporter 
        public class Sample : SimpleControl 
        { 
            private PropertyEditorDialog propertyEditor; 
            private IButtonControl lanuchEditor; 
            private const string SelectSearchIndexCommandName = "SelectSearchIndex"
            private ITextControl searchIndex; 
     
            protected override void InitializeControls(Control controlContainer) 
            { 
                this.propertyEditor = new PropertyEditorDialog(); 
                this.propertyEditor.TypeContainer = this
                this.propertyEditor.PropertyChanged += new PropertyValueChangedEventHandler(propertyEditor_PropertyChanged); 
                this.Controls.Add(this.propertyEditor); 
     
                this.searchIndex = new TextBox(); 
                this.Controls.Add(searchIndex); 
     
                this.lanuchEditor = new Button(); 
                this.lanuchEditor.Text = "Select Search Index"
                this.lanuchEditor.CommandName = SelectSearchIndexCommandName; 
                this.lanuchEditor.CommandArgument = "Telerik.Search.WebControls.IndexingServicesPicker, Telerik.Search"
                this.lanuchEditor.Command += new CommandEventHandler(Sample_Command); 
                this.Controls.Add(this.lanuchEditor); 
            } 
     
            void Sample_Command(object sender, CommandEventArgs e) 
            { 
                if (e.CommandName == SelectSearchIndexCommandName) 
                { 
                    string typeName = e.CommandArgument as string
     
                    string value = String.Empty; 
                    if (this.searchIndex.SelectedIndex != -1) 
                    { 
                        value = this.searchIndex.SelectedValue; 
                    } 
     
                    this.propertyEditor.Show(e.CommandName, typeName, value, this); 
                } 
            } 
     
            void propertyEditor_PropertyChanged(object source, PropertyValueChangedEventArgs e) 
            { 
                if (e.PropertyName == SelectSearchIndexCommandName) 
                { 
                    this.searchIndex.Text = (string)e.PropertyValue; 
                } 
            } 
        } 
     

    Of course, you would be using control references from a template and not directly creating controls in code.

    Best wishes,
    Dido
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Josh
    Josh avatar
    19 posts
    Registered:
    24 Jun 2009
    12 Aug 2009
    Link to this post
    Dido, is it possible to show how this would work in a User Control?

    Example - this is what I have for using the web editor to pick a page:
    [Telerik.Cms.Web.UI.WebEditor("Telerik.Cms.Web.UI.CmsUrlWebEditor, Telerik.Cms")] 
        public string searchResultsPage { getset; } 


    I tried this:
        [Telerik.Cms.Web.UI.WebEditor("Telerik.Search.WebControls.IndexingServicesPicker, Telerik.Search")] 
        public string indexCatalog { getset; } 

    And it works, until i go to choose the index in the UI.  Then i get the dreaded Object reference not set to an instance of an object.

    Any thoughts on what I am doing wrong?

    Josh
  4. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    17 Aug 2009
    Link to this post
    Hello Josh,

    Here is an example of the Indexing Picker control with an User Control. 

    Setup:

    1. IndexingServicesPicker will work only with SearchBox control. In order to use it for other controls you need to put the IndexCatalogCustomPicker.cs in your site's App_Code folder.

    2. I send you an example User control. You need only to add this lines of code to use the indexing picker:
        [Telerik.Cms.Web.UI.WebEditor("Telerik.Search.WebControls.IndexCatalogCustomPicker, App_Code")] 
        public string indexCatalog { getset; }  

    I hope this helps you.

    Sincerely yours,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
4 posts, 0 answered