Exemple #1
0
        public static bool IsDisplayField(SPField field)
        {
            using (new EnterExitLogger("Utilities:IsDisplayField function"))
            {
                bool display = false;

                if (field != null && !field.Hidden && (Array.IndexOf<string>(EXCLUDED_FIELDS, field.InternalName) < 0))
                {
                    switch (field.Type)
                    {
                        case SPFieldType.Computed:
                            if (((SPFieldComputed)field).EnableLookup) { display = true; }
                            break;
                        case SPFieldType.Calculated:
                            if (((SPFieldCalculated)field).OutputType == SPFieldType.Text) { display = true; }
                            break;
                        default:
                            display = true;
                            break;
                    }
                }

                return display;
            }
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedField = field as SPFieldUser;
            var typedFieldModel = fieldModel.WithAssertAndCast<UserFieldDefinition>("model", value => value.RequireNotNull());

            typedField.AllowDisplay = typedFieldModel.AllowDisplay;
            typedField.Presence = typedFieldModel.Presence;
            typedField.AllowMultipleValues = typedFieldModel.AllowMultipleValues;

            if (!string.IsNullOrEmpty(typedFieldModel.SelectionMode))
                typedField.SelectionMode = (SPFieldUserSelectionMode)Enum.Parse(typeof(SPFieldUserSelectionMode), typedFieldModel.SelectionMode);

            if (typedFieldModel.SelectionGroup.HasValue)
            {
                typedField.SelectionGroup = typedFieldModel.SelectionGroup.Value;
            }
            else if (!string.IsNullOrEmpty(typedFieldModel.SelectionGroupName))
            {
                var group = GetCurrentWeb().SiteGroups.OfType<SPGroup>().FirstOrDefault(g => g.Name.ToUpper() == typedFieldModel.SelectionGroupName.ToUpper());
                typedField.SelectionGroup = group.ID;
            }
        }
        protected override void CustomFieldTypeValidation(AssertPair<FieldDefinition, SPField> assert, SPField spObject, FieldDefinition definition)
        {
            var typedObject = spObject as SPFieldLookup;
            var typedDefinition = definition.WithAssertAndCast<LookupFieldDefinition>("model", value => value.RequireNotNull());

            // https://github.com/SubPointSolutions/spmeta2/issues/310
            // AllowMultipleValues - TRUE - LookupMulti
            // AllowMultipleValues - FALSE - Lookup
            assert.ShouldBeEqual((p, s, d) =>
            {
                var srcProp = s.GetExpressionValue(m => m.FieldType);
                var dstProp = d.GetExpressionValue(m => d.TypeAsString);

                var isValid = typedDefinition.AllowMultipleValues
                    ? typedObject.TypeAsString == "LookupMulti"
                    : typedObject.TypeAsString == "Lookup";

                return new PropertyValidationResult
                {
                    Tag = p.Tag,
                    Src = srcProp,
                    Dst = dstProp,
                    IsValid = isValid
                };
            });
        }
        //protected Label LabelRegularExpression;
        public void InitializeWithField(SPField field)
        {
            this.fldCustomFieldTypeRegEx = field as CustomFieldTypeRegEx;

            if (this.Page.IsPostBack)
            {
                return;
            }

            txtRegularExpression.Text = "";
            txtErrorMessage.Text = "";

            if (field != null)
            {
                txtRegularExpression.Text = fldCustomFieldTypeRegEx.propRegularExpression;
                txtErrorMessage.Text = fldCustomFieldTypeRegEx.propErrorMessage;
                //this.txtRegularExpression.Visible = true;
            }
            else
            {
                txtRegularExpression.Text = "";
                txtRegularExpression.Text = "";
                //this.txtRegularExpression.Visible = true;
            }
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            if (!string.IsNullOrEmpty(fieldModel.ValidationMessage))
                field.ValidationMessage = fieldModel.ValidationMessage;

            if (!string.IsNullOrEmpty(fieldModel.ValidationFormula))
                field.ValidationFormula = fieldModel.ValidationFormula;


            var typedFieldModel = fieldModel.WithAssertAndCast<DateTimeFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SPFieldDateTime;

            if (!string.IsNullOrEmpty(typedFieldModel.CalendarType))
                typedField.CalendarType = (SPCalendarType)Enum.Parse(typeof(SPCalendarType), typedFieldModel.CalendarType);

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                typedField.DisplayFormat = (SPDateTimeFieldFormatType)Enum.Parse(typeof(SPDateTimeFieldFormatType), typedFieldModel.DisplayFormat);

#if !NET35
            if (!string.IsNullOrEmpty(typedFieldModel.FriendlyDisplayFormat))
                typedField.FriendlyDisplayFormat = (SPDateTimeFieldFriendlyFormatType)Enum.Parse(typeof(SPDateTimeFieldFriendlyFormatType), typedFieldModel.FriendlyDisplayFormat);
#endif
        }
        private static void ProcessCommonProperties(SPField siteField, FieldDefinition fieldModel)
        {
            siteField.Title = fieldModel.Title;
            siteField.Group = fieldModel.Group;

            // SPBug, description cannot be null
            siteField.Description = fieldModel.Description ?? string.Empty;
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<SummaryLinkFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SummaryLinkField;
        }
        public void InitializeWithField(SPField field)
        {
            this.fldCGMADimensionFieldType = field as CGMADimensionFieldType;

            if (this.Page.IsPostBack)
            {
                return;
            }
        }
 protected virtual void AddTemplateContainer(Control container, SPField field, string className = null) {
     TemplateContainer templateContainer = CreateTemplateContainer(field);
     container.Controls.Add(templateContainer);
     ControlTemplate.InstantiateIn(templateContainer);
     var gridCol = templateContainer.FindControl("GridCol") as HtmlGenericControl;
     if (gridCol == null)
         throw new ArgumentException("Could not find 'GridCol' in FabricListFieldIterator control template.");
     gridCol.Attributes.Add("class", className ?? "col-md-12");
 }
 public void OnSaveChange(SPField field, bool isNewField)
 {
     if (field is RegExpField)
     {
         var Validfield = field as RegExpField;
         Validfield.ValidRegExp = RegExp.Text;
         Validfield.ErrorMessage = ErrorMessage.Text;
     }
 }
		public void Initialize(SPField field, Type propertyType)
		{
			Guard.ThrowIfArgumentNull(field, "field");
			Guard.ThrowIfArgumentNull(propertyType, "propertyType");

			Guard.ThrowIfArgumentNotIs<string>(field.FieldValueType, "field.FieldValueType");

			Field = field;
			PropertyType = propertyType;
		}
		private static IFieldConverter InstantiateConverter(MetaProperty info, SPField field)
		{
			var converter = info.CustomConverterType != null ?
				FieldConverterResolver.Instance.Create(info.CustomConverterType) :
				FieldConverterResolver.Instance.Create(field.TypeAsString);

			converter.Initialize(field, info.MemberType);

			return converter;
		}
Exemple #13
0
        public FieldNode(SPField field)
        {
            this.Tag = field;
            this.SPParent = field.ParentList;
            //this.ContextMenuStrip = SPMMenu.Strips.GetMenu(typeof(FieldMenuStrip));

            Setup();

            //this.Nodes.Add(new ExplorerNodeBase("Dummy"));
        }
 protected virtual TemplateContainer CreateTemplateContainer(SPField field) {
     TemplateContainer templateContainer = new TemplateContainer();
     //templateContainer.ControlMode = base.ControlMode;                    
     PropertyInfo ControlMode = typeof(TemplateContainer).GetProperty("ControlMode", BindingFlags.NonPublic | BindingFlags.Instance);
     ControlMode.SetValue(templateContainer, base.ControlMode);
     //templateContainer.FieldName = field.InternalName;
     PropertyInfo FieldName = typeof(TemplateContainer).GetProperty("FieldName", BindingFlags.NonPublic | BindingFlags.Instance);
     FieldName.SetValue(templateContainer, field.InternalName);
     return templateContainer;
 }
 public SPGENEntityEvalLinqExprArgs(string operand, object value, Expression expr, XmlNode CamlQuery, PropertyInfo sourceProperty, PropertyInfo ownerProperty, SPField field)
 {
     this.Operand = operand;
     this.Value = value;
     this.Expression = expr;
     this.CamlQuery = CamlQuery;
     this.SourceProperty = sourceProperty;
     this.Field = field;
     this.OwnerEntityProperty = ownerProperty;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _web = SPContext.Current.Web;
            _list = _web.Lists[new Guid(Request["ListId"])];
            _field = _list.Fields.TryGetFieldByStaticName(Request["ColumnName"]);
            if (!_list.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
                SPUtility.Redirect(SPUtility.AccessDeniedPage + "?Source=" + SPHttpUtility.UrlKeyValueEncode(_web.Site.MakeFullUrl(Request.RawUrl)), SPRedirectFlags.RelativeToLayoutsPage, Context);

            if (!IsPostBack)
                MessagesLiteral.Text = "Будет выполнено обновление значений поля \"" + _field.Title + "\" из базы данных. Продолжить?";
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var spField = field.WithAssertAndCast<SPFieldUrl>("field", value => value.RequireNotNull());
            var typedFieldModel = fieldModel.WithAssertAndCast<URLFieldDefinition>("model", value => value.RequireNotNull());

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                spField.DisplayFormat = (SPUrlFieldFormatType)Enum.Parse(typeof(SPUrlFieldFormatType), typedFieldModel.DisplayFormat);
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<ComputedFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SPFieldComputed;

            if (typedFieldModel.EnableLookup.HasValue)
                typedField.EnableLookup = typedFieldModel.EnableLookup.Value;
        }
        public static string RenderField(string fieldValue, SPField field)
        {
            System.Text.StringBuilder sb = new StringBuilder();
            try
            {
                SPFieldType type = field.Type;
                switch (type)
                {
                    // Nik20121108 - Handles both Hyperlink and Images
                    case(SPFieldType.URL):
                        if (((SPFieldUrl)field).DisplayFormat == SPUrlFieldFormatType.Image)
                        {
                            string imageUrl = fieldValue.Split(',')[0].Trim();
                            string imageAltTag = fieldValue.Split(',')[1].Trim();
                            sb.AppendLine("<div class=\"wet-boew-lightbox\">");
                            sb.AppendLine("<ul>");
                            sb.AppendLine("<li style=\"list-style-type:none !important;\">");
                            sb.AppendLine("<a class=\"lb-item\" href=\"" + imageUrl + "\" title=\"" + imageAltTag + "\" style=\"list-style-type:none !important;\">");
                            sb.AppendLine("<img class=\"image-actual\" src=\"" + imageUrl + "\" alt=\"" + imageAltTag + "\" style=\"list-style-type:none !important;\" />");
                            sb.AppendLine("</a>");
                            sb.AppendLine("</li>");
                            sb.AppendLine("</ul>");
                            sb.AppendLine("</div>");
                        }
                        else
                            sb.AppendLine("<a href=\"" + fieldValue.Split(',')[0] + "\">" + fieldValue.Split(',')[1] + "</a>");
                        break;
                    case(SPFieldType.Text):case(SPFieldType.Note):case(SPFieldType.Number):
                        sb.AppendLine(fieldValue);
                        break;
                    case(SPFieldType.DateTime):
                        if (((SPFieldDateTime)field).DisplayFormat == SPDateTimeFieldFormatType.DateOnly)
                        {
                            sb.AppendLine(fieldValue.Split(' ')[0]);
                        }
                        else
                            sb.AppendLine(fieldValue);
                        break;
                    case(SPFieldType.Calculated):
                        fieldValue = fieldValue.Replace("string;#", "").Replace("datetime;#", "").Replace("number;#", "");
                        sb.AppendLine(fieldValue);
                        break;
                    default:
                        sb.AppendLine(fieldValue);
                        break;
                }
            }
            catch (Exception ex)
            {
                LogEngine.Log(ex, "Accessible Lists");
            }

            return sb.ToString();
        }
		public void Initialize(SPField field, Type propertyType)
		{
			try
			{
				ConverterInstance.Initialize(field, propertyType);
			}
			catch (Exception e)
			{
				throw new InvalidFieldConverterException(ConverterType, e);
			}
		}
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<ImageFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as ImageField;

            // TODO
            //typedField.NumberOfLines = typedFieldModel.NumberOfLines;
        }
		public void Initialize(SPField field, Type propertyType)
		{
			Guard.ThrowIfArgumentNull(field, "field");
			Guard.ThrowIfArgumentNull(propertyType, "propertyType");

			Guard.ThrowIfArgumentNotIs<SPFieldMultiChoiceValue>(field.FieldValueType, "field.FieldValueType");

			Guard.ThrowIfArgumentNotArrayOrAssignableFromList<string>(propertyType, "propertType");

			
			PropertyType = propertyType;
		}
		public void Initialize(SPField field, Type propertyType)
		{
			Guard.ThrowIfArgumentNull(field, "field");
			Guard.ThrowIfArgumentNull(propertyType, "propertyType");

			Guard.ThrowIfArgumentNotIs<SPFieldGeolocationValue>(field.FieldValueType, "field.FieldValueType");

			Guard.ThrowIfArgumentNotIs<GeoInfo>(propertyType, "propertType");

			Field = field;
			PropertyType = propertyType;
		}
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<NoteFieldDefinition>("model", value => value.RequireNotNull());
            var typedField = field as SPFieldMultiLineText;

            typedField.NumberOfLines = typedFieldModel.NumberOfLines;
            typedField.AppendOnly = typedFieldModel.AppendOnly;
            typedField.RichText = typedFieldModel.RichText;
        }
 public void InitializeWithField(SPField field)
 {
     if (!IsPostBack)
     {
         if (field is RegExpField)
         {
                 var Validfield = field as RegExpField;
                 RegExp.Text = Validfield.ValidRegExp;
                 ErrorMessage.Text = Validfield.ErrorMessage;
         }
     }
 }
		public void Initialize(SPField field, Type propertyType)
		{
			Guard.ThrowIfArgumentNull(field, "field");
			Guard.ThrowIfArgumentNull(propertyType, "propertyType");

			Guard.ThrowIfArgumentNotIs<bool>(field.FieldValueType, "field.FieldValueType");

			Guard.ThrowIfArgumentNotIs(propertyType, new[] { typeof(bool), typeof(bool?) }, "propertType");

			Field = field;
			PropertyType = propertyType;
		}
Exemple #27
0
        public static SPFieldUserValue TryGetFieldUserValue(this SPListItem spListItem, dynamic fieldIdentifier)
        {
            SPFieldUserValue defaultValue = null;
            SPField          field        = null;

            try
            {
                if (fieldIdentifier is Guid)
                {
                    if (!spListItem.Fields.Contains((Guid)fieldIdentifier))
                    {
                        return(defaultValue);
                    }
                    field = spListItem.Fields[(Guid)fieldIdentifier];
                }
                else if (fieldIdentifier is int)
                {
                    if (spListItem.Fields[(int)fieldIdentifier] == null)
                    {
                        return(defaultValue);
                    }
                    field = spListItem.Fields[(int)fieldIdentifier];
                }
                else if (fieldIdentifier is string)
                {
                    if (!spListItem.Fields.ContainsField(fieldIdentifier as string))
                    {
                        if (!spListItem.Fields.ContainsFieldWithStaticName(fieldIdentifier as string))
                        {
                            return(defaultValue);
                        }
                        field = spListItem.Fields.TryGetFieldByStaticName(fieldIdentifier as string);
                    }
                    else
                    {
                        field = spListItem.Fields.GetField(fieldIdentifier as string);
                    }
                }

                if (field == null)
                {
                    return(defaultValue);
                }

                defaultValue = new SPFieldUserValue(spListItem.Web, spListItem[field.Id].ToString());
                return(defaultValue);
            }
            catch
            {
                return(defaultValue);
            }
        }
Exemple #28
0
        private void processProjectInfo(SPWeb web, ref object[] arrDtRow, string project)
        {
            int counter = 6;

            arrDtRow[5] = project;

            if (!hshProjectOC.Contains(project))
            {
                SPList  list  = web.Lists[CoreFunctions.getConfigSetting(web, "EPMLiveProjectCenter")];
                SPQuery query = new SPQuery();
                query.Query = "<Where><Eq><FieldRef Name=\"Title\"/><Value Type=\"Text\">" + project + "</Value></Eq></Where>";
                string vals = "";
                if (list.GetItems(query).Count > 0)
                {
                    SPListItem li = list.GetItems(query)[0];
                    foreach (string s in arrProjectOC)
                    {
                        try
                        {
                            SPField f = list.Fields.GetFieldByInternalName(s);
                            if (f.Type == SPFieldType.Lookup)
                            {
                                string val = li[f.Id].ToString();
                                val  = val.Replace(";#", "\n").Split('\n')[1];
                                vals = vals + "\n" + val;
                            }
                            else
                            {
                                vals = vals + "\n" + li[f.Id].ToString();
                            }
                        }
                        catch { vals = vals + "\n" + " "; }
                    }
                    if (vals.Length > 1)
                    {
                        vals = vals.Substring(1);
                    }
                }
                hshProjectOC.Add(project, vals);
            }

            string sValString = hshProjectOC[project].ToString();

            if (sValString != "")
            {
                string[] sVals = sValString.Split('\n');
                foreach (string s in sVals)
                {
                    arrDtRow[counter++] = s;
                }
            }
        }
Exemple #29
0
        /// <summary>
        /// Gets the format.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns></returns>
        public static string GetFormat(SPField field)
        {
            switch (field.Type)
            {
            case SPFieldType.DateTime:
                return((((SPFieldDateTime)field).DisplayFormat).ToString());

            case SPFieldType.Number:
                var spFieldNumber = (SPFieldNumber)field;

                string percentageSign = string.Empty;

                if (spFieldNumber.ShowAsPercentage)
                {
                    percentageSign = @"\%";
                }

                switch (spFieldNumber.DisplayFormat)
                {
                case SPNumberFormatTypes.Automatic:
                    return(",#0.##########" + percentageSign);

                case SPNumberFormatTypes.NoDecimal:
                    return(",#0" + percentageSign);

                case SPNumberFormatTypes.OneDecimal:
                    return(",#0.0" + percentageSign);

                case SPNumberFormatTypes.TwoDecimals:
                    return(",#0.00" + percentageSign);

                case SPNumberFormatTypes.ThreeDecimals:
                    return(",#0.000" + percentageSign);

                case SPNumberFormatTypes.FourDecimals:
                    return(",#0.0000" + percentageSign);

                case SPNumberFormatTypes.FiveDecimals:
                    return(",#0.00000" + percentageSign);
                }
                return(string.Empty);

            case SPFieldType.Currency:
                return("Currency");

            case SPFieldType.Calculated:
                return(field.Description.Equals("Indicator") ? "Indicator" : string.Empty);

            default:
                return(string.Empty);
            }
        }
Exemple #30
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb currentWeb = properties.Feature.Parent as SPWeb;

            SPList rlist = currentWeb.Lists["Registrations"];
            SPList tlist = currentWeb.Lists["Trainers"];

            SPFieldCollection rFields = rlist.Fields;
            SPFieldCollection tFields = tlist.Fields;

            SPField fullNameField = tFields["Full Name"];

            fullNameField.Required = true;
            fullNameField.Update();

            SPField emailField = tFields["E-mail Address"];

            emailField.Required = true;
            emailField.Update();

            SPField titleField = rFields["Title"];

            titleField.Title = "RegistrationID";
            titleField.Update();

            rFields.Add("First Name", SPFieldType.Text, true);
            rFields.Add("Last Name", SPFieldType.Text, true);
            rFields.Add("E-mail Address", SPFieldType.Text, true);
            rFields.Add("Phone Number", SPFieldType.Text, false);
            rFields.Add("ClassID", SPFieldType.Text, false);
            rlist.Update();

            SPField classIDField = rFields["ClassID"];

            classIDField.ReadOnlyField = true;
            classIDField.Update();


            SPView tDefaultView = tlist.DefaultView;

            tDefaultView.ViewFields.Delete("Attachments");
            tDefaultView.Update();

            SPView rDefaultView = rlist.DefaultView;

            rDefaultView.ViewFields.Delete("Attachments");
            rDefaultView.ViewFields.Add("First Name");
            rDefaultView.ViewFields.Add("Last Name");
            rDefaultView.ViewFields.Add("E-mail Address");
            rDefaultView.ViewFields.Add("Phone Number");
            rDefaultView.Update();
        }
        public static void AddColumn(ColumnDefCollection columns, SPField field)
        {
            if ((from c in columns
                 where c.InternalName.Equals(field.InternalName, StringComparison.CurrentCultureIgnoreCase)
                 select c).Any())
            {
                return;
            }

            SqlParameter p     = GetParameterFromSPField(field);
            string       sType = field.TypeAsString.ToLower();

            switch (field.Type)
            {
            case SPFieldType.Lookup:
            case SPFieldType.User:
                if (sType != "lookupmulti" && sType != "usermulti")
                {
                    columns.Add(new ColumnDef(field.InternalName + "ID", field.InternalName, field.Title, field.Type,
                                              SqlDbType.Int));
                }
                else
                {
                    columns.Add(new ColumnDef(field.InternalName + "ID", field.InternalName, field.Title, field.Type,
                                              p.SqlDbType, p.Size));
                }
                columns.Add(new ColumnDef(field.InternalName + "Text", field.InternalName, field.Title, field.Type,
                                          SqlDbType.NVarChar, 8001));
                //columns.Add(new ColumnDef(field.InternalName + "Text", field.InternalName, field.Title, field.Type, SqlDbType.NText));
                break;

            case SPFieldType.Invalid:
                switch (sType)
                {
                case "filteredlookup":
                    columns.Add(new ColumnDef(field.InternalName + "ID", field.InternalName, field.Title,
                                              SPFieldType.Lookup, SqlDbType.Int));
                    columns.Add(new ColumnDef(field.InternalName + "Text", field.InternalName, field.Title,
                                              SPFieldType.Lookup, SqlDbType.NVarChar, 256));
                    break;

                default:
                    columns.Add(new ColumnDef(field));
                    break;
                }
                break;

            default:
                columns.Add(new ColumnDef(field));
                break;
            }
        }
        protected override bool IsFieldExcluded(SPField field)
        {
            if (!HttpContext.Current.Request[SPConstants.AdminModeUrlParameter].IsNullOrEmpty() && field.ParentList.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
            {
                _controlsToRenderCount++;
                return false;
            }

            var isExcluded = base.IsFieldExcluded(field);

            // This properties are null by default. If they won't be set in content type, field won't be shown in corresponding form
            if ((base.ControlMode == SPControlMode.Display && !field.ShowInDisplayForm.HasValue) ||
                (base.ControlMode == SPControlMode.Edit && !field.ShowInEditForm.HasValue) ||
                (base.ControlMode == SPControlMode.New && !field.ShowInNewForm.HasValue))
                return true;

            if (field.ReadOnlyField)
            {
                // Because it's not posible to override IsFieldExcluded (becouse of many internal fields) I'm checking if field is excluded becouse of Readonly property.
                field.ReadOnlyField = false;
                isExcluded = base.IsFieldExcluded(field) && isExcluded;
                field.ReadOnlyField = true;
            }

            // ContentType selection
            if (field.Type == SPFieldType.Computed && field.InternalName == SPConstants.ContentType)
            {
                var changeContentType = new FPSChangeContentType();
                changeContentType.DisplayName = field.Title;
                var filterItems = field.GetCustomizationValues<string>(CustomPropertyType.Filter) ?? new List<string>();
                var allowedContentTypes = new Dictionary<string, string>();

                foreach (var item in filterItems)
                {
                    var nameValuePair = item.Split('_');
                    if (!allowedContentTypes.ContainsKey(nameValuePair[0]))
                        allowedContentTypes.Add(nameValuePair[0], nameValuePair.Length > 1 ? nameValuePair[1] : null);
                }

                changeContentType.AllowedContentTypes = allowedContentTypes;

                if (!ContentTypeTemplateName.IsNullOrEmpty())
                    changeContentType.TemplateName = ContentTypeTemplateName;

                Controls.Add(changeContentType);
            }

            if (!isExcluded)
                _controlsToRenderCount++;

            return isExcluded;
        }
Exemple #33
0
        private void PopulateCascadeLookupList()
        {
            ddlChildLookup.Items.Clear();

            using (SPWeb web = SPContext.Current.Site.OpenWeb())
            {
                SPField parentField = SPContext.Current.List.TryGetFieldByString(ddlChildList.SelectedValue);
                if (parentField == null)
                {
                    return;
                }

                if (parentField is SPFieldLookup)
                {
                    SPFieldLookup parentFieldLookup = parentField as SPFieldLookup;

                    string parentFieldLookupListGuid = internal_parentListGuid = parentFieldLookup.LookupList;
                    SPList pflList = web.TryGetList(parentFieldLookupListGuid);

                    if (pflList == null)
                    {
                        return;
                    }

                    foreach (SPList list in web.Lists)
                    {
                        foreach (SPField field in list.Fields)
                        {
                            if (field.Type != SPFieldType.Lookup)
                            {
                                continue;
                            }

                            if (parentFieldLookupListGuid == ((SPFieldLookup)field).LookupList)
                            {
                                ListItem item = new ListItem();
                                item.Text  = list.Title;
                                item.Value = list.ID.ToString("B");
                                if (!String.IsNullOrEmpty(CascadeList) && CascadeList == item.Value)
                                {
                                    item.Selected = true;
                                }

                                ddlChildLookup.Items.Add(item);

                                break;
                            }
                        }
                    }
                }
            }
        }
        protected void btnSynch_Click(object sender, EventArgs e)
        {
            SPWeb web = SPContext.Current.Web;

            try
            {
                web.AllowUnsafeUpdates = true;

                string url = CoreFunctions.getConfigSetting(web, "EPMLiveTimePhasedURL");

                if (url != "")
                {
                    ArrayList periods = getPeriods(url);

                    SPList list = web.Lists["EPMLiveTimePhased"];

                    foreach (string period in periods)
                    {
                        try
                        {
                            SPField f = list.Fields.GetFieldByInternalName(period.Replace(" ", "_x0020_"));
                        }
                        catch
                        {
                            list.Fields.Add(period, SPFieldType.Number, false);
                        }
                    }

                    ArrayList arrDelFields = new ArrayList();

                    foreach (SPField f in list.Fields)
                    {
                        if (!f.Hidden && !f.Sealed && f.Type == SPFieldType.Number)
                        {
                            string fName = f.InternalName.Replace("_x0020_", " ");
                            if (!periods.Contains(fName))
                            {
                                arrDelFields.Add(fName);
                            }
                        }
                    }

                    foreach (string fName in arrDelFields)
                    {
                        list.Fields.GetFieldByInternalName(fName.Replace(" ", "_x0020_")).Delete();
                    }

                    Page.RegisterStartupScript("Alert", "<script language=\"javascript\">alert('All Periods have been synchronized');</script>");
                }
            }
            catch { }
        }
Exemple #35
0
        protected override void CreateChildControls()
        {
            this.DisableInputFieldLabel = true;
            base.ControlMode            = SPContext.Current.FormContext.FormMode;
            base.CreateChildControls();
            try
            {
                titleField = (HTML5TitleField)ItemFieldValue;
            }
            catch (Exception)
            {
            }

            _title = ListItem.Fields[SPBuiltInFieldId.Title];

            if (titleField == null)
            {
                titleField = new HTML5TitleField();
            }

            if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New)
            {
                //this.CssClass = "HTML5-editable";
                html_title_hidden = (HiddenField)this.TemplateContainer.FindControl("html_title_hidden");
                html_title        = (Title)this.TemplateContainer.FindControl("html_title");

                if (string.IsNullOrEmpty(titleField.Title))
                {
                    html_title_hidden.Value = _title.GetFieldValueAsHtml(ListItem[SPBuiltInFieldId.Title]);
                    html_title.Controls.AddAt(0, new LiteralControl {
                        Text = _title.GetFieldValueAsHtml(ListItem[SPBuiltInFieldId.Title])
                    });
                    //html_title.Text = _title.GetFieldValueAsHtml(ListItem[SPBuiltInFieldId.Title]);
                }
                else
                {
                    html_title_hidden.Value = titleField.Title;
                    html_title.Controls.AddAt(0, new LiteralControl {
                        Text = titleField.Title
                    });
                    //html_title.Text = titleField.Title;
                }
            }
            else
            {
                html_title = (Title)this.TemplateContainer.FindControl("html_title");
                html_title.Controls.AddAt(0, new LiteralControl {
                    Text = _title.GetFieldValueAsHtml(ListItem[SPBuiltInFieldId.Title])
                });
                //html_title.InnerHtml = _title.GetFieldValueAsHtml(ListItem[SPBuiltInFieldId.Title]);
            }
        }
 private static object GetLookupItemUntype(Type propType, SPField field, object value, FieldAttribute attr)
 {
     try
     {
         var meth        = typeof(EntityMapper).GetMethod("GetLookupItem", BindingFlags.Static | BindingFlags.NonPublic);
         var methGeneric = meth.MakeGenericMethod(propType);
         return(methGeneric.Invoke(null, new[] { field, value, attr }));
     }
     catch (TargetInvocationException e)
     {
         throw e.InnerException;
     }
 }
        public static string GetTextValue(SPField field, string mappingValue)
        {
            var mappings = GetMappings(field);

            if (mappings.ContainsKey(mappingValue))
            {
                return mappings[mappingValue];
            }
            else
            {
                return null;
            }
        }
Exemple #38
0
 public static SPField CreateSiteColumn(SPWeb web, string displayName,
                                        SPFieldType fieldType, string groupDescriptor)
 {
     if (!web.Fields.ContainsField(displayName))
     {
         string  fieldName = web.Fields.Add(displayName, fieldType, false);
         SPField field     = web.Fields.GetFieldByInternalName(fieldName);
         field.Group = groupDescriptor;
         field.Update();
         return(field);
     }
     return(web.Fields[displayName]);
 }
        /// <summary>
        /// Check the specified field on restricted list
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        protected bool FieldInFieldsList(SPField field)
        {
            bool Result = false;

            if (!m_Parameters.IsFieldsFiltered ||
                m_Parameters.FieldList.Contains(field.Title.ToUpper()))
            {
                Result = true;
            }


            return(Result);
        }
Exemple #40
0
        public override void EnsureFieldConfiguration(ref SPWeb web, ref SPField field)
        {
            var typedField = field as SPFieldUser;

            typedField.Title        = DisplayName;
            typedField.Group        = ParentSchema.GroupName;
            typedField.DefaultValue = DefaultValue;
            typedField.Required     = Required;

            typedField.SelectionMode       = SelectionMode;
            typedField.AllowMultipleValues = AllowMultipleValues;
            typedField.Update();
        }
Exemple #41
0
 public void InitializeWithField(SPField field)
 {
     // To check the page post back
     if (!Page.IsPostBack && field != null)
     {
         Documentname              = ((MultipleImageUploadFieldType)field).LibraryName;
         FileCollection            = ((MultipleImageUploadFieldType)field).FileCollection;
         UniqueFolderGuid          = ((MultipleImageUploadFieldType)field).UniqueFolderGuid;
         hidFiles.Value            = FileCollection;
         hidUniqueFolderGuid.Value = UniqueFolderGuid;
         BindDropDown();
     }
 }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast <ComputedFieldDefinition>("model", value => value.RequireNotNull());
            var typedField      = field as SPFieldComputed;

            if (typedFieldModel.EnableLookup.HasValue)
            {
                typedField.EnableLookup = typedFieldModel.EnableLookup.Value;
            }
        }
Exemple #43
0
        public static void UpdateProperties(this SPField field, System.Collections.Generic.Dictionary <string, object> props)
        {
            string schema = field.SchemaXml;

            foreach (var item in props)
            {
                schema = schema.EnsureXmlAttribute(item.Key, item.Value);
            }

            field.SchemaXml = schema;

            field.Update(true);
        }
        /// <summary>
        /// Check list's field for restriction policy
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        protected bool IsInRestrictedFields(SPField field)
        {
            bool Result = false;

            if (m_RestrictedFieldList.Contains(field.Title) ||
                field.ReadOnlyField ||
                field.Type == SPFieldType.Invalid)
            {
                Result = true;
            }

            return(Result);
        }
        public override void EnsureFieldConfiguration(ref SPWeb web, ref SPField field)
        {
            var typedField = field as SPFieldDateTime;

            typedField.Title        = DisplayName;
            typedField.Group        = ParentSchema.GroupName;
            typedField.DefaultValue = DefaultValue;
            typedField.Required     = Required;

            typedField.DisplayFormat         = DisplayFormat;
            typedField.FriendlyDisplayFormat = FriendlyDisplayFormatType;
            typedField.Update();
        }
Exemple #46
0
        public override void EnsureFieldConfiguration(ref SPWeb web, ref SPField field)
        {
            var typedField = field as SPFieldMultiLineText;

            typedField.Title        = DisplayName;
            typedField.Group        = ParentSchema.GroupName;
            typedField.DefaultValue = DefaultValue;
            typedField.Required     = Required;

            typedField.RichText     = RichText;
            typedField.RichTextMode = RichTextMode;
            typedField.Update();
        }
        public override void EnsureFieldConfiguration(ref SPWeb web, ref SPField field)
        {
            var typedField = field as SPFieldMultiChoice;

            typedField.Title        = DisplayName;
            typedField.Group        = ParentSchema.GroupName;
            typedField.DefaultValue = DefaultValue;
            typedField.Required     = Required;

            typedField.Choices.Clear();
            typedField.Choices.AddRange(Choices.ToArray());
            typedField.Update();
        }
        /// <summary>
        /// Get a SiteColumn by display name
        /// </summary>
        /// <param name="teamUrl"></param>
        /// <param name="displayName"></param>
        /// <returns></returns>
        internal SPField GetSiteColumn(string teamUrl, string displayName)
        {
            SPField field = null;

            using (SPWeb spWeb = GetTeamWeb(teamUrl))
            {
                if (spWeb.Fields.ContainsField(displayName))
                {
                    field = spWeb.Fields[displayName];
                }
            }
            return(field);
        }
 /// <summary>
 /// This method is fake and these parameters are required, even though not all of them are used
 /// </summary>
 private void GetFieldSpecialValues(
     SPListItemManager listItemManager,
     SPField spField,
     string stringValue,
     object value,
     out string fieldEditValue,
     out string fieldTextValue,
     out string fieldHtmlValue)
 {
     fieldEditValue = DummyString;
     fieldTextValue = DummyString;
     fieldHtmlValue = DummyString;
 }
Exemple #50
0
        /// <summary>
        /// Gets the targeting field.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns></returns>
        private static SPField GetTargetingField(SPList list)
        {
            SPField field = null;

            try
            {
                field = list.Fields[new Guid("61cbb965-1e04-4273-b658-eedaa662f48d")];
            }
            catch (ArgumentException)
            {
            }
            return(field);
        }
        protected override void ProcessFieldProperties(SPField field, FieldDefinition fieldModel)
        {
            // let base setting be setup
            base.ProcessFieldProperties(field, fieldModel);

            var spField         = field.WithAssertAndCast <SPFieldUrl>("field", value => value.RequireNotNull());
            var typedFieldModel = fieldModel.WithAssertAndCast <URLFieldDefinition>("model", value => value.RequireNotNull());

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
            {
                spField.DisplayFormat = (SPUrlFieldFormatType)Enum.Parse(typeof(SPUrlFieldFormatType), typedFieldModel.DisplayFormat);
            }
        }
Exemple #52
0
        public static string GetCustomAttribue(this SPField sField, string propertyName)
        {
            String sReturn = String.Empty;

            if (sField != null)
            {
                Type       type     = typeof(SPField);
                MethodInfo getField = type.GetMethod("GetFieldAttributeValue", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(String) }, null);
                object     objValue = getField.Invoke(sField, new object[] { propertyName });
                sReturn = Convert.ToString(objValue);
            }
            return(sReturn);
        }
Exemple #53
0
        public string GetFieldLabelForReport(SPField field)
        {
            Debug.Assert(field.Id == this.Id);
            if (!field.Hidden)
            {
                this.EverNotHidden = true;
            }

            int    identityNumber = this.GetFieldIdentityNumber(field);
            string fieldName      = field.Title + ":" + identityNumber.ToString();

            return(field.Hidden ? "(" + fieldName + ")" : fieldName);
        }
        public void OnSaveChange(SPField field, bool isNewField)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite currentSite = new SPSite(SPContext.Current.Site.ID))
                {
                    // Save field properties
                    ImageFieldProperties properties = new ImageFieldProperties
                    {
                        WebId = ddlWebs.SelectedValue,
                        PictureLibraryId = ddlPictureLibrary.SelectedValue,
                        FormatName = tbFormatName.Text,
                        Overwrite = cbOverwrite.Checked,
                        DefaultPictureId = fieldProperties == null ? -1 : fieldProperties.DefaultPictureId
                    };

                    if (!cbClearDefaultPicture.Checked)
                    {
                        if (fuDefaultPicture.HasFile)
                        {
                            // Get the posted file
                            HttpPostedFile file = fuDefaultPicture.PostedFile;

                            if (file.ContentLength > 0)
                            {
                                using (SPWeb web = currentSite.OpenWeb(new Guid(properties.WebId)))
                                {
                                    SPList pictureLibrary = web.Lists[new Guid(properties.PictureLibraryId)];

                                    string uploadedFileName = file.FileName.Substring(file.FileName.LastIndexOf("\\") + 1, file.FileName.LastIndexOf(".") - file.FileName.LastIndexOf("\\") - 1);
                                    string uploadedFileExtension = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1);
                                    string pictureFileName = string.Format("dv_{0}.{1}", Guid.NewGuid().ToString("N"), uploadedFileExtension);
                                    string fileUrl = SPUrlUtility.CombineUrl(pictureLibrary.RootFolder.ToString(), pictureFileName);

                                    // Add the selected picture in the list
                                    SPListItem pictureItem = web.Files.Add(fileUrl, file.InputStream, true).Item;

                                    properties.DefaultPictureId = pictureItem.ID;
                                }
                            }
                        }
                    }
                    else
                    {
                        properties.DefaultPictureId = -1;
                    }

                    FieldManagement<ImageFieldProperties>.SaveProperties(properties);
                }
            });
        }
        private void ProcessField(SPList list, int parentMessageId, XmlNode ndField)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (ndField == null)
            {
                throw new ArgumentNullException(nameof(ndField));
            }
            var  internalName     = ApplicationInstallerHelpers.getAttribute(ndField, "InternalName");
            var  internalFieldXml = ndField.SelectSingleNode("Field");
            var  typeValue        = ApplicationInstallerHelpers.getAttribute(internalFieldXml, "Type");
            bool overwrite;

            bool.TryParse(ApplicationInstallerHelpers.getAttribute(ndField, "Overwrite"), out overwrite);

            var total = ApplicationInstallerHelpers.getAttribute(ndField, "Total");

            SPField spField = null;

            try
            {
                spField = list.Fields.GetFieldByInternalName(internalName);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }

            if (spField == null)
            {
                FieldNewLetsAdd(list, parentMessageId, internalName, internalFieldXml, typeValue);
            }
            else
            {
                FieldExistsSoWeCanUpgrade(
                    list,
                    parentMessageId,
                    internalName,
                    internalFieldXml,
                    typeValue,
                    overwrite,
                    spField);
            }

            if (!string.IsNullOrEmpty(total))
            {
                SaveGridGanttSettings(list, internalName, total);
            }
        }
Exemple #56
0
        /// <summary>
        /// We receive safe field value
        /// </summary>
        /// <typeparam name="T">Type of return value</typeparam>
        /// <param name="spListItem">The SPListItem to get field value</param>
        /// <param name="fieldIdentifier">Guid - Id field, string - the name of the field (display or internal or static), int - the index of the field</param>
        /// <param name="defaultValue">Will returned if something is wrong</param>
        /// <returns>Value of search field in listitem</returns>
        public static T TryGetFieldValue <T>(this SPListItem spListItem, dynamic fieldIdentifier, T defaultValue)
        {
            SPField field = null;

            try
            {
                if (fieldIdentifier is Guid)
                {
                    if (!spListItem.Fields.Contains((Guid)fieldIdentifier))
                    {
                        return(defaultValue);
                    }
                    field = spListItem.Fields[(Guid)fieldIdentifier];
                }
                else if (fieldIdentifier is int)
                {
                    if (spListItem.Fields[(int)fieldIdentifier] == null)
                    {
                        return(defaultValue);
                    }
                    field = spListItem.Fields[(int)fieldIdentifier];
                }
                else if (fieldIdentifier is string)
                {
                    if (!spListItem.Fields.ContainsField(fieldIdentifier as string))
                    {
                        if (!spListItem.Fields.ContainsFieldWithStaticName(fieldIdentifier as string))
                        {
                            return(defaultValue);
                        }
                        field = spListItem.Fields.TryGetFieldByStaticName(fieldIdentifier as string);
                    }
                    else
                    {
                        field = spListItem.Fields.GetField(fieldIdentifier as string);
                    }
                }

                if (field == null)
                {
                    return(defaultValue);
                }

                var value = (T)spListItem[field.Id];
                return(value);
            }
            catch
            {
                return(defaultValue);
            }
        }
        private List <SPField> FindFieldsInProperties(SPView currentView, SPList currentList)
        {
            try
            {
                SPUser         currentUser    = SPContext.Current.Web.CurrentUser;
                UserPermission userPermission = new UserPermission();

                List <SPField> listFields             = new List <SPField>();
                List <SPField> listFieldsInProperties = new List <SPField>();

                if (currentView.ViewFields.Count != 0)
                {
                    foreach (string viewField in currentView.ViewFields)
                    {
                        SPField spfield = currentList.Fields.GetField(viewField);
                        listFields.Add(spfield);
                    }
                }

                if (listFields.Count != 0)
                {
                    foreach (SPField field in listFields)
                    {
                        //Zatial nastavene iba pre DisplayMode
                        if (userPermission.GetFieldPermissionForCurrentUser(field, "Hidden", SPControlMode.Display, true, currentUser, null))
                        {
                            listFieldsInProperties.Add(field);
                            continue;
                        }

                        //if (UserPermission.GetFieldPermissionFromCurrentUser(field, "Hidden", SPControlMode.New, true, currentUser, null))
                        //{
                        //    listFieldsInProperties.Add(field);
                        //    continue;
                        //}

                        //if (UserPermission.GetFieldPermissionFromCurrentUser(field, "Hidden", SPControlMode.Edit, true, currentUser, null))
                        //{
                        //    listFieldsInProperties.Add(field);
                        //    continue;
                        //}
                    }
                }

                return(listFieldsInProperties);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #58
0
        static void ExportTemplate(SPList list)
        {
            Log("Writing AutomatedTagging.csv...");

            Dictionary <SPContentTypeId, List <Guid> > taxonomyFieldsByContentTypeId = new Dictionary <SPContentTypeId, List <Guid> >();

            using (StreamWriter streamWriter = new StreamWriter("AutomatedTagging.csv"))
            {
                streamWriter.WriteLine("Filename,,Field,Tags,Field,Tags,...");
                ContentIterator contentIterator = new ContentIterator();
                contentIterator.ProcessListItems(list,
                                                 delegate(SPListItem listItem)
                {
                    List <Guid> fieldGuids;
                    if (!taxonomyFieldsByContentTypeId.TryGetValue(listItem.ContentTypeId, out fieldGuids))
                    {
                        fieldGuids = new List <Guid>();

                        foreach (SPField field in listItem.ContentType.Fields)
                        {
                            // Alternatively, the code could also support taxonomy fields that can take multiple values here.
                            if (field.TypeAsString == "TaxonomyFieldType")
                            {
                                fieldGuids.Add(field.Id);
                            }
                        }

                        taxonomyFieldsByContentTypeId.Add(listItem.ContentTypeId, fieldGuids);
                    }

                    if (fieldGuids.Count > 0)
                    {
                        streamWriter.Write(listItem.Url + ",");

                        foreach (Guid fieldGuid in fieldGuids)
                        {
                            SPField field = listItem.Fields[fieldGuid];
                            streamWriter.Write("," + field.InternalName + ",");
                        }
                        streamWriter.WriteLine();
                    }
                },
                                                 delegate(SPListItem listItem, Exception e)
                {
                    Debug.WriteLine("Error for item " + listItem.Url
                                    + ": " + e.Message);
                    return(true);
                }
                                                 );
            }
        }
Exemple #59
0
        private void CreateActivityList(Guid siteID, Guid webID, string lstTitle, string desc, string lookupListTitle)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPWeb oWebsite = new SPSite(siteID).AllWebs[webID])
                {
                    oWebsite.AllowUnsafeUpdates = true;
                    try
                    {
                        oWebsite.Lists.Add(lstTitle, desc, SPListTemplateType.GenericList);

                        SPList list = oWebsite.Lists[lstTitle];

                        SPField myField = list.Fields.GetFieldByInternalName("Title");
                        myField.Title   = "活动名称";
                        myField.Update();

                        list.Fields.Add("活动类型", SPFieldType.Text, false);

                        list.Fields.Add("活动对象", SPFieldType.Choice, false);
                        SPFieldChoice spChoice = list.Fields["活动对象"] as SPFieldChoice;
                        spChoice.FillInChoice  = true;
                        spChoice.Choices.Add("教材");
                        spChoice.Choices.Add("编程");
                        spChoice.DefaultValue = spChoice.Choices[0];
                        spChoice.Update();

                        string fieldName  = "计划ID";                                       //新增的Lookup类型字段的名字
                        SPList lookupList = oWebsite.Lists[lookupListTitle];              //设置这个Lookup类型字段要从哪个List中去取值
                        Guid lookupGuid   = new Guid(lookupList.ID.ToString());           // 取得这个Lookup数据源List的Guid
                        list.Fields.AddLookup(fieldName, lookupGuid, false);              //把上面取得的参数引入到AddLookup方法中,从而创建一个Lookup字段
                        SPFieldLookup splookup = list.Fields[fieldName] as SPFieldLookup; //绑定数据List到Lookup字段
                        splookup.LookupField   = "Title";
                        splookup.Update();

                        SPView defaultView = list.Views[0];

                        defaultView.ViewFields.Add(list.Fields["活动类型"]);
                        defaultView.ViewFields.Add(list.Fields["活动对象"]);

                        defaultView.ViewFields.Add(list.Fields["计划ID"]);
                        defaultView.Update();
                        list.Update();
                    }
                    catch
                    {
                    }
                    oWebsite.AllowUnsafeUpdates = false;
                }
            });
        }
        public void OnSaveChange(SPField field, bool isNewField)
        {
            EnsureChildControls();

            _lookupFieldEditor.OnSaveChange(field, isNewField);

            field.SetFieldAttribute("Filter", filterTextBox.Text);
            field.SetFieldAttribute("MaxHeight", maxHeightTextBox.Text);
            field.SetFieldAttribute("MaxRows", maxRowsTextBox.Text);
            field.SetFieldAttribute("MinLength", minLengthTextBox.Text);
            field.SetFieldAttribute("TitleField", titleFieldTextBox.Text);
            field.SetFieldAttribute("ValueField", valueFieldTextBox.Text);
            field.SetFieldAttribute("DescriptionFields", descriptionFieldsTextBox.Text);
        }