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

Forums / Developing with Sitefinity / Using DhlUrlEditor in ControlDesiger

Using DhlUrlEditor in ControlDesiger

4 posts, 0 answered
  1. Chris Hofgen
    Chris Hofgen avatar
    3 posts
    Registered:
    06 Apr 2006
    03 Sep 2008
    Link to this post
    Hi,
     
    I want to make use of the DhlUrlEditor in a ControlDesigner template. Is this possible? So like instead of using the PageSelector
     

    <sfLib:ButtonSelector runat="server" ButtonText="Select" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx" AssociatedControls="imageURLTextBox" />


    Or is it possible to get the pageId from the PageSelector also?

    Thx
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Sep 2008
    Link to this post
    Hi Chris Hofgen,

    Thank you for your post.
    Could you please elaborate a bit more about what you want to achieve? You may find the following forum thread helpful Pre-existing select node site map WebEditor.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Chris Hofgen
    Chris Hofgen avatar
    3 posts
    Registered:
    06 Apr 2006
    08 Sep 2008
    Link to this post
    Hi,

    I hope I can make it more clear.

    I have a control where I use the DhlUrlEditor like in the  Pre-existing select node site map WebEditor, you pointed out to me. 
     
    But now I want to use that WebEditor in a ControlDesigner or PropertyDesinger. I am not sure what the correct name is.
    I mean like in the image control, with the "Basic" and "advanced" tab
    in the CtrlProbs page.  Where on the "Basic" tab you have a nicer layout
    voor editing you control properies.

    So I have a "ControlDesigner" class with a "Layout" template ascx.
    And I want to use the DhlUrlEditor in that "Layout" template. Selecting
    PageId and Url and putting in textboxes on the Layout template.

    Somethink like you do in you ImageDialog control in UserControls/Dialogs where you use the  pageSelector.

    I hope this is more clear description of my problem

  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    09 Sep 2008
    Link to this post
    Hi Chris,

    Thanks a lot for the additional explanation.

    Here is a sample implementation of the DynamicHyperLink control designer that demonstrates how to achieve the required functionality (note that DynamicHyperLink control has the required properties: NavigateUrl and PageId):

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using Telerik.Cms.Web.UI;  
     
    namespace MyLibrary  
    {  
        public class DynamicHyperLinkControlDesigner : 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 = (DynamicHyperLink)base.DesignedControl;  
     
                    this.editorDialog = new PropertyEditorDialog();  
                    this.editorDialog.TypeContainer = this.component;  
                    this.editorDialog.PropertyChanged += new PropertyValueChangedEventHandler(editorDialog_PropertyChanged);  
                    this.Controls.Add(this.editorDialog);  
     
                    IButtonControl btnNavigateUrl = this.FindControl("NavigateUrlPicker"as IButtonControl;  
                    if (btnNavigateUrl != null)  
                    {  
                        btnNavigateUrl.CommandName = "Telerik.Cms.Web.UI.DhlUrlEditor, Telerik.Cms";  
                        btnNavigateUrl.CommandArgument = "NavigateUrl";  
                        btnNavigateUrl.Command += new CommandEventHandler(btn_Command);  
                    }  
     
                    txtNavigateUrl = this.FindControl("NavigateUrl"as IEditableTextControl;  
                    if (txtNavigateUrl != null)  
                    {  
                        txtNavigateUrl.TextChanged += new EventHandler(Txt_TextChanged);  
                        txtNavigateUrl.Text = component.NavigateUrl;  
                    }  
                }  
            }  
     
            void editorDialog_PropertyChanged(object source, PropertyValueChangedEventArgs e)  
            {  
                this.component.NavigateUrl = e.PropertyValue as string;  
                txtNavigateUrl.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, txtNavigateUrl.Text, component);  
            }  
     
            private ITemplate itemTemplate;  
            private PropertyEditorDialog editorDialog;  
            private DynamicHyperLink component;  
            private IEditableTextControl txtNavigateUrl;  
     
            private class DefaultItemTemplate : ITemplate  
            {  
                public void InstantiateIn(Control container)  
                {  
                    TextBox txtNavigateUrl = new TextBox();  
                    txtNavigateUrl.ID = "NavigateUrl";  
                    container.Controls.Add(txtNavigateUrl);  
     
                    LinkButton btnNavigateUrl = new LinkButton();  
                    btnNavigateUrl.ID = "NavigateUrlPicker";  
                    btnNavigateUrl.Text = "Select";  
                    container.Controls.Add(btnNavigateUrl);  
                }  
            }  
        }  

    To test the provided example you need to add the class in App_Code folder and register it in the <controlDesigners> section of the web.config file:

    <controlDesigners> 
            ...  
            <add key="Telerik.Cms.Web.UI.DynamicHyperLink" value="MyLibrary.DynamicHyperLinkControlDesigner, App_Code"/> 

    Do let us know if this helps.

    Sincerely yours,
    Pepi
    the Telerik team

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