> private static void SetTooltip(object pForm, string pstrControlName, string pstrPropName, string pstrValue) > { > try > { > object ctlX; > > try > { > if (pstrControlName.Trim().ToUpper() == "ME") > { > ctlX = pForm; > } > else > { > ctlX = pForm.GetType().GetProperty(pstrControlName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.Instance).GetValue(pForm, null); > } > } > catch > { > // Le contrôle n'a pas été trouvé! > return; > } > try > { > Type MyType = ctlX.GetType(); >// System.Reflection.PropertyInfo Mypropertyinfo = MyType.GetProperty(pstrPropName); >// >// Mypropertyinfo.SetValue(ctlX, pstrValue, null); > > foreach(System.Reflection.PropertyInfo pi in MyType.GetProperties()) > { > if (pi.Name.ToUpper() == "AlternateText".ToUpper() && pi.CanWrite) > { > pi.SetValue(MyType, pstrValue, null); > } > if (pi.Name.ToUpper() == pstrPropName.ToUpper() && pi.CanWrite) > { > System.Reflection.MethodInfo methodInfo = pi.GetSetMethod(true); > System.Reflection.BindingFlags bindingFlags = System.Reflection.BindingFlags.SetProperty; > if (methodInfo.IsStatic) > bindingFlags |= System.Reflection.BindingFlags.Static; > pi.SetValue(MyType, pstrValue, bindingFlags, null, null, null); > >// pi.SetValue(MyType, pstrValue, null); > } > } > > } > catch (Exception ex) > { > return; > } > } > catch (Exception ex) > { > int i = 0; > } > } >Eric,
private void SetPropertyValue(string pstrControlName, string pstrPropName, string pstrValue) { Control c = this.FindControl(pstrControlName); if ( c != null ) { PropertyInfo pi = c.GetType().GetProperty(pstrPropName,pstrValue.GetType()); if (pi != null && pi.CanWrite) pi.SetValue(c,pstrValue,null); } }Cetin