Пример #1
0
        public static string GetFormControlValue(Page p, int MaxValue, string DelimCol, string DelimRow)
        {
            StringBuilder sb = new StringBuilder();

            Control[] aCtl = CWebControl.GetControls(p);
            foreach (Control ctl in aCtl)
            {
                string Path     = GetPath(ctl, ".");
                string ID       = ctl.ID;
                string TypeName = ctl.GetType().Name;

                string PropertyName = "";

                //Literal은 내용이 너무 많으므로 제외함.

                if ((ctl is TextBox) || (ctl is Label))
                {
                    PropertyName = "Text";
                }
                else if (ctl is ListControl)
                {
                    PropertyName = "SelectedValue";
                }
                else if (ctl is CheckBox)
                {
                    PropertyName = "Checked";
                }
                else if (ctl is UserControl)
                {
                    //uc_inputip_ascx와 같이 구성됨.
                    //보류
                    string Name = ctl.GetType().Name;
                    if (Name.StartsWith("uc_") && Name.EndsWith("_ascx"))
                    {
                        string UscName = Name.Split('_')[1];
                    }
                }

                if ((ID == null) || (PropertyName == ""))
                {
                    continue;
                }

                string Value = CReflection.GetFieldOrPropertyValue(ctl, PropertyName).ToString();
                if (Value.Length > MaxValue)
                {
                    Value = Value.Substring(0, MaxValue);
                }

                sb.Append(Path + "." + ID + "." + PropertyName + DelimCol + Value.ToString() + DelimRow);
            }

            return(sb.ToString());
        }
Пример #2
0
 /// <summary>
 /// Convert.ChangeType은 Enum 형식을 제대로 변환하지 못하므로 Enum 형식에 대한 변환을 추가함.
 /// 문자열 "0", "1"의 경우 bool로 바로 변경하면 에러나므로 int로 변경후 bool로 변환을 추가함.
 /// </summary>
 /// <param name="Value"></param>
 /// <param name="ConversionType"></param>
 /// <returns></returns>
 public static object ChangeType(string Value, Type ConversionType)
 {
     if (ConversionType.IsEnum)
     {
         return(CReflection.GetEnumValueByInt32(ConversionType, Convert.ToInt32(Value)));
     }
     else if (ConversionType == typeof(bool))
     {
         return(Convert.ToBoolean(Convert.ToInt32(Value)));
     }
     else
     {
         return(Convert.ChangeType(Value, ConversionType));
     }
 }