Ejemplo n.º 1
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()
        {
            base.CreateChildControls();
            Controls.Clear();
            RockControlHelper.CreateChildControls(this, Controls);

            _date    = new TextBox();
            _date.ID = "tbDate";
            _date.AddCssClass("form-control js-datetime-date");
            Controls.Add(_date);

            _time    = new TextBox();
            _time.ID = "tbTime";
            _time.AddCssClass("form-control js-datetime-time");
            Controls.Add(_time);

            _cbCurrent    = new RockCheckBox();
            _cbCurrent.ID = "cbCurrent";
            _cbCurrent.AddCssClass("js-current-datetime-checkbox");
            _cbCurrent.Text = "Current Time";
            this.Controls.Add(_cbCurrent);

            _nbTimeOffset      = new RockTextBox();
            _nbTimeOffset.ID   = "nbTimeOffset";
            _nbTimeOffset.Help = "Enter the number of minutes after the current time to use as the date. Use a negative number to specify minutes before.";
            _nbTimeOffset.AddCssClass("input-width-md js-current-datetime-offset");
            _nbTimeOffset.Label = "+- Minutes";
            this.Controls.Add(_nbTimeOffset);

            RequiredFieldValidator.ControlToValidate = _date.ID;
        }
        public void BaseNullTollerance()
        {
            var control = new TextBox()
            {
                CssClass = NullString
            };

            control.CssClass.Should().Be("");

            control.AddCssClass(NullString);
            control.CssClass.Should().Be("");

            control.AddCssClass("          ");
            control.CssClass.Should().Be("");

            control.RemoveCssClass(NullString);
            control.CssClass.Should().Be("");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is where you implment the simple aspects of rendering your control.  The rest
        /// will be handled by calling RenderControlHelper's RenderControl() method.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void RenderBaseControl(HtmlTextWriter writer)
        {
            if (this.Visible)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "form-control-group js-datetime-picker-container " + this.CssClass);
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                if (IsCurrentTimeOffset)
                {
                    _date.Attributes["disabled"] = "true";
                    _date.AddCssClass("aspNetDisabled");
                    _time.Enabled         = false;
                    _nbTimeOffset.Enabled = true;
                }
                else
                {
                    _date.Enabled         = true;
                    _time.Enabled         = true;
                    _nbTimeOffset.Enabled = false;
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "input-group input-width-md date");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                _date.RenderControl(writer);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "input-group-addon");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write("<i class='fa fa-calendar'></i>");
                writer.RenderEndTag();
                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "bootstrap-timepicker input-group input-width-md");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                _time.RenderControl(writer);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "input-group-addon");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write("<span class='add-on'><i class='fa fa-clock-o'></i></span>");
                writer.RenderEndTag();
                writer.RenderEndTag();

                if (DisplayCurrentOption)
                {
                    _cbCurrent.RenderControl(writer);
                    _nbTimeOffset.RenderControl(writer);
                }

                writer.RenderEndTag();   // form-control-group
            }
        }