System.Web.UI.WebControls.BaseValidator.GetValidationProperty C# (CSharp) Method

GetValidationProperty() public static method

public static GetValidationProperty ( object o ) : PropertyDescriptor
o object
return PropertyDescriptor
		public static PropertyDescriptor GetValidationProperty (object o)
		{
			PropertyDescriptorCollection props;
			System.ComponentModel.AttributeCollection col;

			props = TypeDescriptor.GetProperties (o);
			col = TypeDescriptor.GetAttributes (o);

			foreach (Attribute at in col) {
				ValidationPropertyAttribute vpa = at as ValidationPropertyAttribute;
				if (vpa != null && vpa.Name != null)
					return props[vpa.Name];
			}

			return null;
		}

Usage Example

Example #1
0
        protected string GetControlValidationValue(string name)
        {
            Control control = NamingContainer.FindControl(name);

            if (control == null)
            {
                return(null);
            }

            PropertyDescriptor prop = BaseValidator.GetValidationProperty(control);

            if (prop == null)
            {
                return(null);
            }

            object o = prop.GetValue(control);

            if (o == null)
            {
                return(String.Empty);
            }

            if (o is ListItem)
            {
                return(((ListItem)o).Value);
            }

            return(o.ToString());
        }
All Usage Examples Of System.Web.UI.WebControls.BaseValidator::GetValidationProperty