Exemple #1
0
        public void AddControl(System.Web.UI.ControlCollection ControlliWeb, ParentType _myParent)
        {
            foreach (System.Web.UI.Control _Controllo in ControlliWeb)
            {
                clMyControl _myColl = new clMyControl(_myParent);

                if (_Controllo is System.Web.UI.WebControls.TextBox)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.TextBox)_Controllo).Text;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.TextBox)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.HtmlControls.HtmlInputHidden)
                {
                    _myColl.Valore        = ((System.Web.UI.HtmlControls.HtmlInputHidden)_Controllo).Value;
                    _myColl.NomeControllo = ((System.Web.UI.HtmlControls.HtmlInputHidden)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.WebControls.Label)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.Label)_Controllo).Text;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.Label)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.WebControls.CheckBox)
                {
                    _myColl.Valore        = Convert.ToString(((System.Web.UI.WebControls.CheckBox)_Controllo).Checked);
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.CheckBox)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.WebControls.ListBox)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.ListBox)_Controllo).SelectedValue;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.ListBox)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.WebControls.DropDownList)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.DropDownList)_Controllo).SelectedValue;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.DropDownList)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }
                if (_Controllo is System.Web.UI.WebControls.RadioButton)
                {
                    _myColl.Valore        = Convert.ToString(((System.Web.UI.WebControls.RadioButton)_Controllo).Checked);
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.RadioButton)_Controllo).ClientID;
                    _myArray.Add(_myColl);
                }


                if (_Controllo.Controls.Count > 0)
                {
                    AddControl(_Controllo.Controls, _myParent);
                }
            }
        }
        private void SetVal(System.Web.UI.ControlCollection ControlliWeb, Hashtable _HS, int pagina)
        {
            clMyControl _myColl = new clMyControl();

            foreach (System.Web.UI.Control _Controllo in ControlliWeb)
            {
                if (_Controllo is System.Web.UI.WebControls.TextBox)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.TextBox)_Controllo).Text;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.TextBox)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.HtmlControls.HtmlInputHidden)
                {
                    _myColl.Valore        = ((System.Web.UI.HtmlControls.HtmlInputHidden)_Controllo).Value;
                    _myColl.NomeControllo = ((System.Web.UI.HtmlControls.HtmlInputHidden)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.WebControls.Label)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.Label)_Controllo).Text;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.Label)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.WebControls.CheckBox)
                {
                    _myColl.Valore        = Convert.ToString(((System.Web.UI.WebControls.CheckBox)_Controllo).Checked);
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.CheckBox)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.WebControls.ListBox)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.ListBox)_Controllo).SelectedValue;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.ListBox)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.WebControls.DropDownList)
                {
                    _myColl.Valore        = ((System.Web.UI.WebControls.DropDownList)_Controllo).SelectedValue;
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.DropDownList)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }
                if (_Controllo is System.Web.UI.WebControls.RadioButton)
                {
                    _myColl.Valore        = Convert.ToString(((System.Web.UI.WebControls.RadioButton)_Controllo).Checked);
                    _myColl.NomeControllo = ((System.Web.UI.WebControls.RadioButton)_Controllo).ClientID + pagina.ToString();

                    string id = _myColl.NomeControllo;
                    if (_HS.ContainsKey(id))
                    {
                        _HS.Remove(id);
                    }
                    _HS.Add(id, _myColl.Valore);
                }

                if (_Controllo.Controls.Count > 0)
                {
                    SetVal(_Controllo.Controls, _HS, pagina);
                }
            }
        }