示例#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>
        /// ASP.Net에선 ReadOnly가 true이면 PostBack시에 값을 읽지 않으므로 강제로 값을 설정함.
        /// Master Page의 Page_Load 이벤트에서 호출할 것
        /// </summary>
        /// <param name="p"></param>
        public static void SetReadOnlyTextBoxValueWhenPostBack(Page p)
        {
            if (!p.IsPostBack)
            {
                return;
            }

            Control[] aCtl = CWebControl.GetControls(p);
            foreach (Control Ctl in aCtl)
            {
                TextBox txt = Ctl as TextBox;
                if (txt == null)
                {
                    continue;
                }

                if (txt.ReadOnly)
                {
                    txt.Text = p.Request.Form[txt.UniqueID];
                }
            }
        }