Applying the TypeConverter attribute to a property (C#) : TypeConverter « Custom Controls « ASP.NET Tutorial






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

namespace WebControlLibrary1
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class WebCustomControl1 : WebControl
    {
        private string text;
        private Guid _bookid;

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        public string Text
        {
            get
            {
                return text;
            }
            set
            {
                text = value;
            }
        }

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [TypeConverter(typeof(GuidConverter))]
        public Guid BookId
        {
            get
            {
                return _bookid;
            }

            set
            {
                _bookid = value;
            }
        }


        protected override void Render(HtmlTextWriter output)
        {
            output.RenderBeginTag(HtmlTextWriterTag.Input);
            output.RenderEndTag();
        }
    }
}








14.17.TypeConverter
14.17.1.Applying the TypeConverter attribute to a property (C#)
14.17.2.Applying the TypeConverter attribute to a property (VB)
14.17.3.Creating a custom type converter (C#)
14.17.4.Creating a custom type converter (VB)