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

Forums / Developing with Sitefinity / Control Designer in combination with Property Designer

Control Designer in combination with Property Designer

7 posts, 0 answered
  1. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    24 Jan 2008
    Link to this post
    Hello

    I developed a Control Designer to combine RadEditor and 4 Textboxes. This controlDesigner works fine.

    But I want to have also a PropertyDesigner for the 4 textboxes so that I can define the value of the textbox with a seperate UserControl.
    So in other words: I want to have a select button behind each Textbox. When I select the Select Button a UserControl popups that let me define the value of the Textbox.

    Is this combination possible like the way you define Property Designers or should I solve it by myself with our own popup window?

    Regards
    Luc
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    24 Jan 2008
    Link to this post
    Hi Luc Baeten,

    Please, refer to the following blog post that discusses how to implement a complex property editor (the window that opens when the user clicks "Select" button and lets him visually determine the value of the property).

    Hope this is helpful.

    Greetings,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    24 Jan 2008
    Link to this post
    Hi Pepi

    Thanks for your reaction. I already saw this post. But what I want to know (and how) the complex property editor can be combined with the control designer? I donwloaded the example of the ControlDesigner (http://www.sitefinity.com/ClientsFiles/065208_ControlDesignerExample.zip) from your site (blog item http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-badamb.aspx)

    In App_Code/ControlDesigner.cs I have the textboxes defined like:

    public TextBox CardsDistributionSouth
    {
    get
    {
    if (this.cardsdistributionsouth == null)
    this.cardsdistributionsouth = base.FindRequiredControl<TextBox>("CardsDistributionSouth");

    return this.cardsdistributionsouth;
    }
    }


    Adding  [Browsable(true)] [WebEditor "~/UserControls/SelectCards.ascx")] above the Textbox declaration is not enough. At least it doesn't show me the Select button.

    Should I solve it in another way?

    Regards
    Luc
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    25 Jan 2008
    Link to this post
    Hi Luc,

    The WebEditor attribute receives as a parameter the name of the type. The type name contains full name of the selector class and the assembly where it can be found - "Sample.Quotes.QuotesSelector, Sample.Quotes". So you cannot pass the path to some User Control to the WebEditor constructor. You need to create a custom control that will represent your selector.

    Regarding your question about the Select button in the control designer, you need to add your own button next to the textbox that will open the selector. It will not be generated dynamically as in the Properties window. Here is an example how to make a control designer for the ASP NET Image control. Pay attention to the fact that CommandName of the Select button should be set to the type name of the selector class and CommandArgument to the name of the designed property.

    using Telerik.Cms.Web.UI; 
     
    namespace MyLibrary 
        public class AspImageControlDesigner : Telerik.Framework.Web.Design.ControlDesigner 
        { 
            protected override void CreateChildControls() 
            { 
                this.Controls.Clear(); 
     
                if (this.itemTemplate == null
                { 
                    this.itemTemplate = new DefaultItemTemplate(); 
                } 
                this.itemTemplate.InstantiateIn(this); 
     
                if (base.DesignedControl != null
                { 
                    component = (Image)base.DesignedControl; 
     
                    IButtonControl btn = this.FindControl("picker"as IButtonControl; 
                    if (btn != null
                    { 
                        this.editorDialog = new PropertyEditorDialog(); 
                        this.editorDialog.TypeContainer = this
                        this.editorDialog.PropertyChanged += new PropertyValueChangedEventHandler(editorDialog_PropertyChanged); 
                        this.Controls.Add(this.editorDialog); 
     
                        btn.CommandName = "Telerik.FileManager.UrlWebEditor, Telerik.FileManager"
                        btn.CommandArgument = "ImageUrl"
                        btn.Command += new CommandEventHandler(btn_Command); 
                    } 
     
                    txt = this.FindControl("ImageUrl"as IEditableTextControl; 
                    if (txt != null
                    { 
                        txt.TextChanged += new EventHandler(Txt_TextChanged); 
                        txt.Text = component.ImageUrl; 
                    } 
                } 
            } 
     
            void editorDialog_PropertyChanged(object source, PropertyValueChangedEventArgs e) 
            { 
                this.component.ImageUrl = e.PropertyValue as string
                txt.Text = e.PropertyValue as string
     
                base.OnPropertyChanged(EventArgs.Empty); 
            } 
     
            void Txt_TextChanged(object sender, EventArgs e) 
            { 
                base.UpdateProperty(sender, component); 
            } 
            
            void btn_Command(object sender, CommandEventArgs e) 
            { 
                string name = (string)e.CommandArgument; 
                this.editorDialog.Show(name, e.CommandName, txt.Text, component); 
            } 
     
            private PropertyEditorDialog editorDialog; 
            private Image component;  
            private IEditableTextControl txt; 
     
            private class DefaultItemTemplate : ITemplate 
            { 
                public void InstantiateIn(Control container) 
                { 
                    TextBox txt = new TextBox(); 
                    txt.ID = "ImageUrl"
                    container.Controls.Add(txt); 
     
                    LinkButton btn = new LinkButton(); 
                    btn.ID = "picker"
                    btn.Text = "Select"
                    container.Controls.Add(btn); 
                } 
            } 
        } 
     

    Also, you could find useful information about the control designers in the Developers Manual -> Controls -> Control Designers.

    Hope this helps.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Luc Baeten
    Luc Baeten avatar
    169 posts
    Registered:
    23 Sep 2005
    25 Jan 2008
    Link to this post
    Thanks Pepi

    I will try it !

    regards
    Luc
  6. Olivier
    Olivier avatar
    11 posts
    Registered:
    13 May 2008
    16 Jun 2008
    Link to this post
    Hi,

    I'm currently implementing a sitefinity module and i have to include some complex properties selectors inside of my administration editor.
    I've been able to open a dialog (thanks to this thread) that opens me a custom control for retrieving some values i need, but when i'm clicking the "i'm done" or "cancel" button , nothing happens, the editor stay there and i'm not getting any values back, i'm sure i forgot to add some code in order to be notified, but i could not find it.
    Is there something trivial i am missing?

    Thanks

    Olivier
  7. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    16 Jun 2008
    Link to this post
    Hello Olivier,

    Since this is an old Forum Thread and the information included in it is for a previous Sitefinity release, we would like to kindly ask you to open a new thread, including all relevant information for your inquiry. This would help everybody - you, the community and us, since it will help us structure our database better, and reply faster, and everyone would be able to search in it depending on the information's accuracy.

    Thank you very much for your effort and understanding.

    Sincerely yours,
    Nikifor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
7 posts, 0 answered