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

Forums / Designing with Sitefinity / How to display custom label which contains the description of a property

How to display custom label which contains the description of a property

2 posts, 0 answered
  1. eraashishgupta
    eraashishgupta avatar
    50 posts
    Registered:
    26 Nov 2008
    23 Jan 2009
    Link to this post
    I want a label to display some message after a property which is both getter and setter.
    This label is just like the description attribute which is represented by default as ? in front of the property name.
    I just want to have that description as a label next to the property text box so that its more user friendly as my client is not so technical he might not spot out the ?

    So is there a  way to do this.
    I just want [Description("")] attribute to be displayed in a label next to my property in a particular user control.

    Or is there a way to just display the label inside the admin section for a particular user control only.

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Jan 2009
    Link to this post
    Hi,

    Here is a simple example that will return the description of a give property when click event is fired. This should be implemented for your approach.

        [Description("here is my desc")] 
        public string Desc 
        { 
            get { return desc; } 
            set { desc = value; } 
        } 
     
        private string desc; 
     
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            System.ComponentModel.AttributeCollection attributes = TypeDescriptor.GetProperties(this)["Desc"].Attributes; 
            DescriptionAttribute myAttribute = (DescriptionAttribute)attributes[typeof(DescriptionAttribute)]; 
            Response.Write(myAttribute.Description); 
        } 

    All the best,
    Ivan Dimitrov
    the Telerik team

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