More in this section

Forums / Developing with Sitefinity / Custom Control Desin

Custom Control Desin

2 posts, 0 answered
  1. Daniel L
    Daniel L avatar
    26 posts
    Registered:
    06 May 2006
    22 Feb 2008
    Link to this post
    Hi,
     I have created a custom control design for one of my custom modules. I have actually got custom control design to load in the window upon click edit. And got my custom edit form to load as well. The problem is I cannot  get my values to save to my properties for my module. I looked at the documentation and example from the site but nothing worked for me. What I have is a save button and an onclick event for the save where I attempt to save the values to the properties of my module. I tied four different ways and got nothing. For example:

    //This I got from example code
    base.UpdateProperty(ExpiredText, base.DesignedControl);
     
    //This I also got from example code, Note: The CountdownBase is a base
    //class that my module inherits from and contains my properties ((LyntonWeb.Cms.Modules.CountDownBase)base.DesignedControl).ExpiredText = ExpiredText.Text;

    //This is the SetProperty function that is in //Telerik.Framework.Web.Design.ControlDesigner
     SetProperty((LyntonWeb.Cms.Modules.CountDownBase)base.DesignedControl, pdc, "ExpiredText", ExpiredText.Text, out descriptor);


    //This is also an idea I pulled from the SiteFinity documentation file this is a //PropertyDescriptorCollection that gets the properties from my base class and
    //I attempted to set them this way

    myPropertyDescriptorCollection["CountDownText"].SetValue((LyntonWeb.Cms.Modules.CountDownBase)base.DesignedControl, CountDownText.Text);

    I tried all these and the values where still not saving to my properties.
    Any suggestions?

     
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    25 Feb 2008
    Link to this post
    Hello Daniel,

    If I understand correctly, you have created a control designer of a custom control and you are having problems  updating property values of the control.

    To achieve this, you could use the UpdateProperty method of the ControlDesignerBase class that is the base class for control designers. This method sets the value of the component (designed custom control) to the new property value. Here is a simple example for updating the ImageUrl property of ASP.NET Image control:

            protected override void CreateChildControls() 
            { 
                ... 
                 
                if (base.DesignedControl != null
                { 
                    component = (Image)base.DesignedControl; 
     
                     
                    this.txtImageUrl.TextChanged += new EventHandler(Txt_TextChanged); 
                    this.txtImageUrl.Text = component.ImageUrl; 
     
                ... 
            } 
     
            void Txt_TextChanged(object sender, EventArgs e) 
            { 
                base.UpdateProperty(sender, component); 
            } 

    If this does not help you solve the issue, please send us both your designer and the designed control to localize what is wrong.

    Thanks for your cooperation in advance.

    Regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered