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

Forums / Sitefinity SDK / how to make communication between user controller and Controll Designer ?

how to make communication between user controller and Controll Designer ?

8 posts, 0 answered
  1. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    09 Dec 2010
    Link to this post
    HI,

    how to make communication between user controller and Controll Designer  in sitefinity 4.0 ? for Example

    1. i created user control a.ascx

    2. i created control designer adesigner.ascx for a.ascx user control.

    how do i connect(communicate) both user control and control desinger ?


    thanks
    Humayoo
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    09 Dec 2010
    Link to this post
    Hi humayoo,

    You cannot have a control designer for a user control you have to use a custom control. You can use ControlDesigner attribute to connect the control to the designer

    sample

    [ControlDesigner(typeof(YourDesigner))]
    public class MyClass : Simpleview
    {
     // do something
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    09 Dec 2010
    Link to this post
    hi,

    i am getting trouble.please see my code and suggest me where am i wrong?

    1. created user control and its name is frontuser.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="frontuser.ascx.cs" Inherits="controls_test_frontuser" %>
      
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    2. i created control designer and its name is FrontUserControlDesigner.ascx

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
        <sitefinity:ResourceLinks id="resourcesLinks" runat="server">
        <sitefinity:ResourceFile JavaScriptLibrary="JQuery" />
        <sitefinity:ResourceFile Name="Skins/Grid.css" />
        <sitefinity:ResourceFile Name="Skins/ToolBar.css" />
        <sitefinity:ResourceFile Name="Skins/Ajax.css" />
    </sitefinity:ResourceLinks>
       
       
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
       
    <telerik:RadTreeView id="RadTreeView1" runat="server" DataSourceID="SiteMapDataSource1" Skin="Sitefinity" OnClientNodeClicked="function() {return false;}" >
            <DataBindings>
                <telerik:RadTreeNodeBinding ValueField="Id" />
            </DataBindings>
        </telerik:RadTreeView>
    </div>
       
    <p class="sfButtonArea sfSelectorBtns">
        <asp:LinkButton ID="DoneButton" runat="server" OnClientClick="return false;" CssClass="sfLinkBtn sfSave">DoneButton</asp:LinkButton>
        <asp:Literal ID="literalOr" runat="server" Text="<%$Resources:Labels, or %>" />
        <asp:LinkButton ID="CancelButton" runat="server" CssClass="sfCancel" OnClientClick="return false;">CancelButton</asp:LinkButton>
    </p>

    3. custom class( or  Designer class whatever ) is

    using Telerik.Sitefinity.Web.UI;
    using Telerik.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.Generic;
    using System.Web.UI;
    using System;
    using Telerik.Sitefinity.Web.UI.ControlDesign;
      
    [ControlDesigner(typeof("~/controls/test/WebUserControl.ascx"))]
    public class CustomDialogSelector : SimpleScriptView
    {
        #region Public Methods
      
        public bool CheckBoxes
        {
            get;
            set;
        }
      
        #endregion
      
        #region Properties
      
      
      
        protected override string LayoutTemplateName
        {
            get
            {
                return "~/controls/test/frontuser.ascx";
            }
        }
      
        private RadTreeView SiteMapTreeView
        {
            get
            {
                return Container.GetControl<RadTreeView>();
            }
        }
      
        private LinkButton DoneButton
        {
            get
            {
                return Container.GetControl<LinkButton>("DoneButton", true);
            }
        }
      
        private string UseCheckboxes
        {
            get
            {
                return this.CheckBoxes.ToString().ToLower();
            }
        }
      
        private LinkButton CancelButton
        {
            get
            {
                return Container.GetControl<LinkButton>("CancelButton", true);
            }
        }
      
        public string OnDoneClientSelection
        {
            get;
            set;
        }
      
        #endregion
      
        #region Methods
      
        /// <summary>
        /// Gets a collection of script descriptors that represent (JavaScript) client components.
        /// </summary>
        public override IEnumerable<System.Web.UI.ScriptDescriptor> GetScriptDescriptors()
        {
            var descriptor = new ScriptControlDescriptor(this.GetType().FullName, this.ClientID);
            descriptor.AddComponentProperty("siteMapTree", SiteMapTreeView.ClientID);
      
      
            descriptor.AddElementProperty("doneButton", DoneButton.ClientID);
            descriptor.AddElementProperty("cancelButton", CancelButton.ClientID);
            descriptor.AddProperty("checkboxes", UseCheckboxes);
            if (!string.IsNullOrEmpty(this.OnDoneClientSelection))
                descriptor.AddEvent("doneClientSelection", this.OnDoneClientSelection);
            return new[] { descriptor };
        }
      
        /// <summary>
        /// Gets a collection of objects that define script resources that the control requires.
        /// </summary>
        public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
        {
            // here you can return reference to a custom script that your control
            // will use.
            string assembly = this.GetType().Assembly.GetName().ToString();
            List<ScriptReference> res = new List<ScriptReference>{
                   new ScriptReference(selectorScript, assembly),
               };
            return res;
        }
      
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            var controlSiteMap = this.SiteMapTreeView;
            controlSiteMap.CheckBoxes = this.CheckBoxes;
            controlSiteMap.DataBind();
            controlSiteMap.ExpandAllNodes();
      
        }
      
        protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
        {
        }
        #endregion
      
        #region Fields
      
        private const string selectorScript = "Telerik.Sitefinity.Samples.AlterScript.js";
        private const string templatePath = "Telerik.Sitefinity.Resources.Templates.Samples.PageTemplate.ascx";
        #endregion
    }

    i put frontuser.ascx in place holder of template so user can view.
    from administrator login when user edit this control,  control desinger (frontusercontroldesinger.ascx)  view must be there(like page selector). but it was not working.

    i want to make page selector .make guide me where am i wrong?

    thanks
    Humayoo
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    09 Dec 2010
    Link to this post
    Hello humayoo,

    Please check this post where it is show how to create page selector. You are also missing the javascript code where you should bind the RadTreeView on the client and persist selected nodes.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Jeff
    Jeff avatar
    9 posts
    Registered:
    29 Nov 2009
    12 Jan 2011
    Link to this post
    Ivan, did I undestand you correctly in your above posting that there is no way to add a custom control designer to my user control?  (You said: "You cannot have a control designer for a user control you have to use a custom control").  Did you mean to say that you can't use a user control AS a control designer, or that you can't use a control designer with a user control?

    I knew that the control designer itself could not be a user control.  It must be a custom control.  But do I have to convert my existing user control into a custom control just so that I can add a user friendly control designer?

    I have a usercontrol I use in Sitefinity 3.7 for which I have written a control designer and I am attempting to convert it.  I tried starting from scratch following the NewsRotator example, but so far all my experiements have failed.  I used the The control designer seems to work and it pops up but it is always empty and even the Save and Cancel buttons do nothing.  I want to make sure that what I am attempting is even possible before I spend any more days on this.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Jan 2011
    Link to this post
    Hi Jeff,

    I sent you a link to the documentation from where you can get a sample code. There is a SDK from where you can download the entire sample.

    In 3.x you cannot use ControlDesigner with a user control as well. There is not such a scenario that we have showed somewhere. We have always used custom controls that inherit from CompositeControl, SimpleControl or ContentView control.

    You are getting some issues with the designer, because the template is not set correctly or there is a problem with the java script ( if the problem is related to the java scrip there must be an error in the browser console)

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Jeff
    Jeff avatar
    9 posts
    Registered:
    29 Nov 2009
    13 Jan 2011
    Link to this post
    I'm not trying to make a control designer _with_ a user control.  I'm trying to make one _for_ a user control.  Just like in your article here:

    http://www.sitefinity.com/blogs/ivan/post/08-04-23/how_to_create_a_control_designer_for_user_controls.aspx

    I've done this in Sitefinity 3.7 but I was wondering if this is still possible in 4.  The tutorial only mentions creating control designers for custom controls. Based on your response, I think the answer must be yes, but it seems I hadn't made my question clear yet.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Jan 2011
    Link to this post
    Hi,

    Actually you will be able to do this. You need to use ControlDesigner attribute in your user control.

    [Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesigner(typeof(MyControlDesigner))]
    public partial class ButtonTest : System.Web.UI.UserControl
    {

    }



    Best wishes,
    Ivan Dimitrov
    the Telerik team

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