How to make Custom control 's property being shown in the properties window?

goodmorningsky

Centurion
Joined
Aug 18, 2003
Messages
172
I make Validator : System.Web.UI.WebControls.CustomValidator
class.
and defined ValidationType property which is type of ValidateType.
I want to make the proerty is shown with Extended dropdown menu in properties window of Design mode.
I did following but, it doesn't show.
How can I do it?

Code:
using System;
using System.Web.UI; 
using System.ComponentModel;
namespace TestControls
{
	/// <summary>
	/// Summary description for Validator.
	/// </summary>
	[DefaultProperty("ValidationType")]
	public class Validator : System.Web.UI.WebControls.CustomValidator
	{
		public Validator()
		{
		}
		private ValidateType _validateType;
		[Bindable(true), Browsable(true),
		Category("Appearance"),
		TypeConverter(typeof(ValidateType))]
		public ValidateType ValidationType
		{
			set
			{
				_validateType = value;
				switch(_validateType)
				{
					case ValidateType.Email:
						this.ClientValidationFunction="OnValidate_Email";
						this.ErrorMessage = "Test Error";
						break;
				}
			}
		}
	}
}
using System;

namespace TestControls
{

	public enum ValidateType
	{
		Email = 1,
		Phone = 2,
	}
}
 
Back
Top