Example #1
0
        protected virtual ControlMonitorInfo ResolveControlMonitorParameter(ControlMonitorParameter cmp)
        {
            ControlMonitorInfo result        = new ControlMonitorInfo();
            Control            targetControl = FindControl(cmp.TargetID);

            result.TargetId = targetControl.ClientID;
            result.Callback = Page.ClientScript.GetPostBackClientHyperlink(targetControl, "");

            ICollection <string> validatorsToResolve = cmp.ResolveValidators(Page);

            foreach (string validatorToResolve in validatorsToResolve)
            {
                result.Validators.Add(FindControl(validatorToResolve).ClientID);
            }
            return(result);
        }
Example #2
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     if (context != null)
     {
         Predicate <IComponent>  visitor   = null;
         ControlMonitorParameter parameter = context.Instance as ControlMonitorParameter;
         Control targetControl             = null;
         if (((parameter != null) && !string.IsNullOrEmpty(parameter.TargetID)) && ((parameter.Owner != null) && (parameter.Owner.Site != null)))
         {
             IDesignerHost service       = (IDesignerHost)parameter.Owner.Site.GetService(typeof(IDesignerHost));
             Control       rootComponent = service.RootComponent as Control;
             if (rootComponent != null)
             {
                 if (visitor == null)
                 {
                     visitor = delegate(IComponent component)
                     {
                         Control control = component as Control;
                         if ((control != null) && string.Equals(control.ID, parameter.TargetID, StringComparison.InvariantCultureIgnoreCase))
                         {
                             targetControl = control;
                             return(true);
                         }
                         return(false);
                     };
                 }
                 ControlMonitorParameterUtil.WalkControlTree(rootComponent, visitor, true, parameter.Owner);
             }
         }
         if (targetControl != null)
         {
             List <string> values = new List <string>();
             foreach (EventDescriptor descriptor in TypeDescriptor.GetEvents(targetControl))
             {
                 values.Add(descriptor.Name);
             }
             if (values.Count > 0)
             {
                 values.Sort(StringComparer.OrdinalIgnoreCase);
                 return(new TypeConverter.StandardValuesCollection(values));
             }
         }
     }
     return(base.GetStandardValues(context));
 }