Пример #1
0
        /// <Summary>RenderEditMode renders the Edit mode of the control</Summary>
        /// <Param name="writer">A HtmlTextWriter.</Param>
        protected override void RenderEditMode(HtmlTextWriter writer)
        {
            int length = Null.NullInteger;

            if (CustomAttributes != null)
            {
                foreach (Attribute attribute in CustomAttributes)
                {
                    if (attribute is MaxLengthAttribute)
                    {
                        MaxLengthAttribute lengthAtt = (MaxLengthAttribute)attribute;
                        length = lengthAtt.Length;
                    }
                }
            }

            ControlStyle.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
            writer.AddAttribute(HtmlTextWriterAttribute.Value, StringValue);
            if (length > Null.NullInteger)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, length.ToString());
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
            writer.RenderBeginTag(HtmlTextWriterTag.Input);
            writer.RenderEndTag();
        }
Пример #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetEditorInfo builds an EditorInfo object for a propoerty
        /// </summary>
        /// <history>
        ///     [cnurse]	05/05/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private EditorInfo GetEditorInfo()
        {
            string CategoryDataField             = Convert.ToString(FieldNames["Category"]);
            string EditorDataField               = Convert.ToString(FieldNames["Editor"]);
            string NameDataField                 = Convert.ToString(FieldNames["Name"]);
            string RequiredDataField             = Convert.ToString(FieldNames["Required"]);
            string TypeDataField                 = Convert.ToString(FieldNames["Type"]);
            string ValidationExpressionDataField = Convert.ToString(FieldNames["ValidationExpression"]);
            string ValueDataField                = Convert.ToString(FieldNames["Value"]);
            string VisibilityDataField           = Convert.ToString(FieldNames["ProfileVisibility"]);
            string MaxLengthDataField            = Convert.ToString(FieldNames["Length"]);

            var          editInfo = new EditorInfo();
            PropertyInfo property;

            //Get the Name of the property
            editInfo.Name = string.Empty;
            if (!String.IsNullOrEmpty(NameDataField))
            {
                property = DataSource.GetType().GetProperty(NameDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Name = Convert.ToString(property.GetValue(DataSource, null));
                }
            }

            //Get the Category of the property
            editInfo.Category = string.Empty;

            //Get Category Field
            if (!String.IsNullOrEmpty(CategoryDataField))
            {
                property = DataSource.GetType().GetProperty(CategoryDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Category = Convert.ToString(property.GetValue(DataSource, null));
                }
            }

            //Get Value Field
            editInfo.Value = string.Empty;
            if (!String.IsNullOrEmpty(ValueDataField))
            {
                property = DataSource.GetType().GetProperty(ValueDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Value = Convert.ToString(property.GetValue(DataSource, null));
                }
            }

            //Get the type of the property
            editInfo.Type = "System.String";
            if (!String.IsNullOrEmpty(TypeDataField))
            {
                property = DataSource.GetType().GetProperty(TypeDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Type = Convert.ToString(property.GetValue(DataSource, null));
                }
            }

            //Get Editor Field
            editInfo.Editor = "DotNetNuke.UI.WebControls.TextEditControl, DotNetNuke";
            if (!String.IsNullOrEmpty(EditorDataField))
            {
                property = DataSource.GetType().GetProperty(EditorDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Editor = EditorInfo.GetEditor(Convert.ToInt32(property.GetValue(DataSource, null)));
                }
            }

            //Get LabelMode Field
            editInfo.LabelMode = LabelMode.Left;

            //Get Required Field
            editInfo.Required = false;
            if (!String.IsNullOrEmpty(RequiredDataField))
            {
                property = DataSource.GetType().GetProperty(RequiredDataField);
                if (!((property == null) || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Required = Convert.ToBoolean(property.GetValue(DataSource, null));
                }
            }

            //Set ResourceKey Field
            editInfo.ResourceKey = editInfo.Name;
            editInfo.ResourceKey = string.Format("{0}_{1}", Name, editInfo.Name);

            //Set Style
            editInfo.ControlStyle = new Style();

            //Get Visibility Field
            editInfo.ProfileVisibility = new ProfileVisibility
            {
                VisibilityMode = UserVisibilityMode.AllUsers
            };
            if (!String.IsNullOrEmpty(VisibilityDataField))
            {
                property = DataSource.GetType().GetProperty(VisibilityDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.ProfileVisibility = (ProfileVisibility)property.GetValue(DataSource, null);
                }
            }

            //Get Validation Expression Field
            editInfo.ValidationExpression = string.Empty;
            if (!String.IsNullOrEmpty(ValidationExpressionDataField))
            {
                property = DataSource.GetType().GetProperty(ValidationExpressionDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.ValidationExpression = Convert.ToString(property.GetValue(DataSource, null));
                }
            }

            //Get Length Field
            if (!String.IsNullOrEmpty(MaxLengthDataField))
            {
                property = DataSource.GetType().GetProperty(MaxLengthDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    int length     = Convert.ToInt32(property.GetValue(DataSource, null));
                    var attributes = new object[1];
                    attributes[0]       = new MaxLengthAttribute(length);
                    editInfo.Attributes = attributes;
                }
            }

            //Remove spaces from name
            editInfo.Name = editInfo.Name.Replace(" ", "_");
            return(editInfo);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetEditorInfo builds an EditorInfo object for a propoerty
        /// </summary>
        /// <history>
        /// 	[cnurse]	05/05/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private EditorInfo GetEditorInfo()
        {
            string CategoryDataField = Convert.ToString(FieldNames["Category"]);
            string EditorDataField = Convert.ToString(FieldNames["Editor"]);
            string NameDataField = Convert.ToString(FieldNames["Name"]);
            string RequiredDataField = Convert.ToString(FieldNames["Required"]);
            string TypeDataField = Convert.ToString(FieldNames["Type"]);
            string ValidationExpressionDataField = Convert.ToString(FieldNames["ValidationExpression"]);
            string ValueDataField = Convert.ToString(FieldNames["Value"]);
            string VisibilityDataField = Convert.ToString(FieldNames["ProfileVisibility"]);
            string MaxLengthDataField = Convert.ToString(FieldNames["Length"]);

            var editInfo = new EditorInfo();
            PropertyInfo property;

            //Get the Name of the property
            editInfo.Name = string.Empty;
            if (!String.IsNullOrEmpty(NameDataField))
            {
                property = DataSource.GetType().GetProperty(NameDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Name = Convert.ToString(property.GetValue(DataSource, null));
                }
            }
			
            //Get the Category of the property
            editInfo.Category = string.Empty;
			
			//Get Category Field
            if (!String.IsNullOrEmpty(CategoryDataField))
            {
                property = DataSource.GetType().GetProperty(CategoryDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Category = Convert.ToString(property.GetValue(DataSource, null));
                }
            }
            
			//Get Value Field
			editInfo.Value = string.Empty;
            if (!String.IsNullOrEmpty(ValueDataField))
            {
                property = DataSource.GetType().GetProperty(ValueDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Value = Convert.ToString(property.GetValue(DataSource, null));
                }
            }
            
			//Get the type of the property
			editInfo.Type = "System.String";
            if (!String.IsNullOrEmpty(TypeDataField))
            {
                property = DataSource.GetType().GetProperty(TypeDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Type = Convert.ToString(property.GetValue(DataSource, null));
                }
            }
            
			//Get Editor Field
			editInfo.Editor = "DotNetNuke.UI.WebControls.TextEditControl, DotNetNuke";
            if (!String.IsNullOrEmpty(EditorDataField))
            {
                property = DataSource.GetType().GetProperty(EditorDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Editor = EditorInfo.GetEditor(Convert.ToInt32(property.GetValue(DataSource, null)));
                }
            }
			
            //Get LabelMode Field
            editInfo.LabelMode = LabelMode.Left;

            //Get Required Field
            editInfo.Required = false;
            if (!String.IsNullOrEmpty(RequiredDataField))
            {
                property = DataSource.GetType().GetProperty(RequiredDataField);
                if (!((property == null) || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.Required = Convert.ToBoolean(property.GetValue(DataSource, null));
                }
            }
			
            //Set ResourceKey Field
            editInfo.ResourceKey = editInfo.Name;
            editInfo.ResourceKey = string.Format("{0}_{1}", Name, editInfo.Name);

            //Set Style
            editInfo.ControlStyle = new Style();

            //Get Visibility Field
            editInfo.ProfileVisibility = new ProfileVisibility
                                             {
                                                 VisibilityMode = UserVisibilityMode.AllUsers
                                             };
            if (!String.IsNullOrEmpty(VisibilityDataField))
            {
                property = DataSource.GetType().GetProperty(VisibilityDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.ProfileVisibility = (ProfileVisibility)property.GetValue(DataSource, null);
                }
            }
			
            //Get Validation Expression Field
            editInfo.ValidationExpression = string.Empty;
            if (!String.IsNullOrEmpty(ValidationExpressionDataField))
            {
                property = DataSource.GetType().GetProperty(ValidationExpressionDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    editInfo.ValidationExpression = Convert.ToString(property.GetValue(DataSource, null));
                }
            }
			
			//Get Length Field
            if (!String.IsNullOrEmpty(MaxLengthDataField))
            {
                property = DataSource.GetType().GetProperty(MaxLengthDataField);
                if (!(property == null || (property.GetValue(DataSource, null) == null)))
                {
                    int length = Convert.ToInt32(property.GetValue(DataSource, null));
                    var attributes = new object[1];
                    attributes[0] = new MaxLengthAttribute(length);
                    editInfo.Attributes = attributes;
                }
            }
			
			//Remove spaces from name
            editInfo.Name = editInfo.Name.Replace(" ", "_");
            return editInfo;
        }