More in this section

Forums / Developing with Sitefinity / Creating a default value for a user control property

Creating a default value for a user control property

2 posts, 0 answered
  1. Ken
    Ken avatar
    13 posts
    Registered:
    02 Jan 2012
    16 Dec 2011
    Link to this post
    In Sitefinity 3.x you used to be able to add the [DefaultValue()] Attribute to a property. This doesn't seem to be supported anymore in SF 4 - is there a new way to initialize properties with default values? Should this be done in the control's constructor?
  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    21 Dec 2011
    Link to this post
    Hello,

    I believe a similar code should do the work:
    private string _name;
    [DefaultValue("James")]
    public string Name
        get
        {
        return  _name;
        }
        set
        {
        _name = value;
        }


    Greetings,
    Jen Peleva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered