Inheritance: System.Web.UI.WebControls.CompositeControl, IRockControl
Esempio n. 1
0
        /// <summary>
        /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control"/>
        /// object that child controls and templates belong to. These child controls are in
        /// turn defined within an inline template.
        /// </summary>
        /// <param name="container">The <see cref="T:System.Web.UI.Control"/> object to contain the instances of controls from the inline template.</param>
        public void InstantiateIn( Control container )
        {
            DataControlFieldCell cell = container as DataControlFieldCell;
            if ( cell != null )
            {
                ToggleField toggleField = cell.ContainingField as ToggleField;
                ParentGrid = toggleField.ParentGrid;
                DataField = toggleField.DataField;
                bool isEnabled = false;
                bool.TryParse(toggleField.Enabled, out isEnabled );
                Enabled = isEnabled;

                Toggle toggle = new Toggle();
                toggle.OnText = toggleField.OnText;
                toggle.OffText = toggleField.OffText;
                toggle.OnCssClass = toggleField.OnCssClass;
                toggle.OffCssClass = toggleField.OffCssClass;

                //toggle.EnableViewState = true; // TODO remove if unnecessary
                toggle.ActiveButtonCssClass = toggleField.ActiveButtonCssClass;
                toggle.ButtonSizeCssClass = toggleField.ButtonSizeCssClass;
                toggle.CheckedChanged += toggle_CheckedChanged;
                toggle.DataBinding += toggle_DataBinding;
                toggle.PreRender += toggle_PreRender;

                cell.Controls.Add( toggle );
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            Controls.Clear();

            toggleAllAny = new Toggle();
            Controls.Add( toggleAllAny );
            toggleAllAny.ID = this.ID + "_toggleAllAny";
            toggleAllAny.ButtonSizeCssClass = "btn-xs";
            toggleAllAny.OnText = "All";
            toggleAllAny.OffText = "Any";
            toggleAllAny.ActiveButtonCssClass = "btn-info";

            btnAddGroup = new LinkButton();
            Controls.Add( btnAddGroup );
            btnAddGroup.ID = this.ID + "_btnAddGroup";
            btnAddGroup.Click += btnAddGroup_ServerClick;
            btnAddGroup.AddCssClass( "btn btn-action" );
            btnAddGroup.CausesValidation = false;

            var iAddGroup = new HtmlGenericControl( "i" );
            iAddGroup.AddCssClass( "fa fa-list-alt" );
            btnAddGroup.Controls.Add( iAddGroup );
            btnAddGroup.Controls.Add( new LiteralControl( " Add Filter Group" ) );

            btnAddFilter = new LinkButton();
            Controls.Add( btnAddFilter );
            btnAddFilter.ID = this.ID + "_btnAddFilter";
            btnAddFilter.Click += btnAddFilter_ServerClick;
            btnAddFilter.AddCssClass( "btn btn-action" );
            btnAddFilter.CausesValidation = false;

            var iAddFilter = new HtmlGenericControl( "i" );
            iAddFilter.AddCssClass( "fa fa-filter" );
            btnAddFilter.Controls.Add( iAddFilter );
            btnAddFilter.Controls.Add( new LiteralControl( " Add Filter" ) );

            lbDelete = new LinkButton();
            Controls.Add( lbDelete );
            lbDelete.ID = this.ID + "_lbDelete";
            lbDelete.Click += lbDelete_Click;
            lbDelete.AddCssClass( "btn btn-xs btn-danger" );
            lbDelete.CausesValidation = false;

            var iDeleteGroup = new HtmlGenericControl( "i" );
            iDeleteGroup.AddCssClass( "fa fa-times" );
            lbDelete.Controls.Add( iDeleteGroup );
        }