Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

Make new property show up in markup and in the control properties

public GlobalMethods.InfoGatherKind GatherKind
        {
            get
            {
                return GlobalMethods.igatherkind;
            }
        }

I want to be able to set the GatherKind in the markup and the control Properties.  How do I do this please?

I know it is an attribute of some sort above the property name [Persist...] or something or other.

ASKER CERTIFIED SOLUTION
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Knowlton

ASKER

  [BrowsableAttribute(true)]
        public GlobalMethods.InfoGatherKind GatherKind
        {
            get
            {
                return GlobalMethods.igatherkind;
            }

            set
            {
                GlobalMethods.igatherkind = value;
            }
        }

        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;

                Attributes["value"] = value;
            }
        }

Open in new window




It shows up in the Properties window now but is greyed-out

and...

it still does not show up in the markup attributes (in the HTML)
Nevermind...


This seems to be working well...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.ComponentModel;


//Taken from
//
//http://www.codeproject.com/KB/custom-controls/ASPNET_Password_TextBox.aspx

namespace Campus_Webstore
{   

    public class TextBoxWithCustomAttributes : TextBox
    {        
        public TextBoxWithCustomAttributes()
        {
         
        }

        [Category("Kinds")]
        [BrowsableAttribute(true)]
        public GlobalMethods.InfoGatherKind GatherKind
        {
            get
            {
                return GlobalMethods.igatherkind;
            }

            set
            {
                GlobalMethods.igatherkind = value;
            }
        }

        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;

                Attributes["value"] = value;
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Attributes["value"] = Text;
        }
    }
}

Open in new window

thx!