private void RegisterEnumTypes(UserSettings objUserSettings) { foreach (UserSettingsCategory category in objUserSettings.Categories) { foreach (PropertyValue pv in category.Properties) { if (pv.Definition.DataType == PropertyDataType.Enum && pv.Definition.EditorParams.IsNotEmpty()) { this.PropertyGrid1.PredefinedEnumTypes.Add(pv.Definition.EditorParams); } #region “由于没有给PropertyGrid 数据源,没有加载对应的客户端验证” ydz foreach (PropertyValidatorDescriptor propValidator in pv.Definition.Validators) { Validator vali = propValidator.GetValidator(); if (vali is IClientValidatable) { ClientVdtAttribute cvArt = new ClientVdtAttribute(propValidator); if (string.IsNullOrEmpty(cvArt.ClientValidateMethodName) == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), cvArt.ClientValidateMethodName, ((IClientValidatable)vali).GetClientValidateScript(), true); } } } #endregion } } }
private void Page_PreRenderComplete(object sender, EventArgs e) { foreach (PropertyValue prop in this.Properties) { foreach (PropertyValidatorDescriptor propValidator in prop.Definition.Validators) { Validator vali = propValidator.GetValidator(); if (vali is IClientValidatable) { ClientVdtAttribute cvArt = new ClientVdtAttribute(propValidator); if (string.IsNullOrEmpty(cvArt.ClientValidateMethodName) == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), cvArt.ClientValidateMethodName, ((IClientValidatable)vali).GetClientValidateScript(), true); } } } } }