More in this section

Forums / Developing with Sitefinity / Complex templated control properties are not persisted

Complex templated control properties are not persisted

4 posts, 0 answered
  1. Flavio Cometto
    Flavio Cometto avatar
    14 posts
    Registered:
    17 Oct 2009
    27 Apr 2010
    Link to this post
    Hi all,
    I'm developing a solution on Sistefinity Standard 3.7 SP2 and this is what happens:

    I have a control derived from SimpleControl with a RadTabstrip and a RadMultiPage inside. In one view there is another control (again derived from SimpleControl). This scenario is quite similar to that described in blog post http://www.sitefinity.com/blogs/radoslavgeorgiev/posts/10-01-21/tabbed_blog_controls.aspx.
    In the parent control I have exposed a public property in order to manage child control properties, here the code:
    [Category("Projects")]
    public ProjectSimpleList DraftProjectList
    {
         get
         {
               return FindControl<ProjectSimpleList>("draftProjects");
         }
         set
         {
                this.DraftProjectsList = value;
         }
    }

    In the child control a have a public property in order to specify a detail page url to get to. The code is:
    [WebEditor("Telerik.Cms.Web.UI.CmsUrlWebEditor, Telerik.Cms"), Category("Navigation"),
             DefaultValue((string)null)]
    public string ProjectNavigateUrl { get; set; }

    As You can see I use CmsUrlWebEditor facilities to select the required page.
    So thats seems fine but the child property "ProjectNavigateUrl" is not persisted, infact when the control run in public side this property is null.
    Right now the only workaround I found is set this property directy in the markup of the parent control (as you can see below).

    <telerik:RadMultiPage ID="rmpMainMultiPage" runat="server" SelectedIndex="0">  
                    <telerik:RadPageView ID="viewProjects" runat="server">
                        <cc2:ProjectSimpleList ID="draftProjects" runat="server"   
                                                    ShowModeType="Draft" PrivateMode="true"
                                                    ProjectNavigateUrl="~/Projects/ProjectDetail.aspx" >
                        </cc2:ProjectSimpleList >
                    </telerik:RadPageView>

    So what is wrong?
    Thank You in advance and best regards.

    Flavio
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Apr 2010
    Link to this post
    Hi Flavio Cometto,

    Try using a ViewState property instead. You could also check whether your property is set before calling CreateChildControls or InitializeControls of ProjectSimpleList control. If this is the case you should create separate property that will hold the url.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Flavio Cometto
    Flavio Cometto avatar
    14 posts
    Registered:
    17 Oct 2009
    27 Apr 2010
    Link to this post
    Thank Ivan,
    I think You suggest to use an approach similiar that explained in this post http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/complex-control-properties-persist-for-admin-but-not-for-public.aspx right?

    But just to understand I'm wondering why "standard" property like font, border, etc. are persisted and "user" property not, although I'm use string type that is default property type Sitefinity use to persists its values.
    Again, this means that it can not persists automatically the property of complex controls incorporated into other controls?

    Thanks.

    Flavio
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Apr 2010
    Link to this post
    Hi Flavio Cometto,

    If the property gets set before calling CreateChildControls or InitializeControls then its value is override and as a result you get empty string or null. The properties like font and border comes from WebControl class.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered