/// <summary>
        /// Creates a <see cref="TextBox"/> control to use for rendering the <see cref="BocTextValueBase"/> control in edit mode.
        /// </summary>
        /// <returns>A <see cref="TextBox"/> control with the all relevant properties set and all appropriate styles applied to it.</returns>
        protected virtual TextBox GetTextBox(BocRenderingContext <T> renderingContext)
        {
            TextBox textBox = new RenderOnlyTextBox {
                ClientIDMode = ClientIDMode.Static
            };

            textBox.Text            = renderingContext.Control.Text;
            textBox.ID              = renderingContext.Control.GetValueName();
            textBox.EnableViewState = false;
            textBox.Enabled         = renderingContext.Control.Enabled;
            textBox.ReadOnly        = !renderingContext.Control.Enabled;
            textBox.Width           = Unit.Empty;
            textBox.Height          = Unit.Empty;
            textBox.ApplyStyle(renderingContext.Control.CommonStyle);
            renderingContext.Control.TextBoxStyle.ApplyStyle(textBox);

            return(textBox);
        }
Пример #2
0
        /// <summary>
        /// Creates a <see cref="TextBox"/> control to use for rendering the <see cref="BocTextValueBase"/> control in edit mode.
        /// </summary>
        /// <returns>A <see cref="TextBox"/> control with the all relevant properties set and all appropriate styles applied to it.</returns>
        protected virtual TextBox GetTextBox(BocRenderingContext <T> renderingContext)
        {
            TextBox textBox = new RenderOnlyTextBox {
                Text = renderingContext.Control.Text
            };

            textBox.ID = renderingContext.Control.GetValueName();
            textBox.EnableViewState = false;
            textBox.Enabled         = renderingContext.Control.Enabled;
            textBox.ReadOnly        = !renderingContext.Control.Enabled;
            textBox.Width           = Unit.Empty;
            textBox.Height          = Unit.Empty;
            textBox.ApplyStyle(renderingContext.Control.CommonStyle);
            renderingContext.Control.TextBoxStyle.ApplyStyle(textBox);
            if (textBox.TextMode == TextBoxMode.MultiLine && textBox.Columns < 1)
            {
                textBox.Columns = c_defaultColumns;
            }

            return(textBox);
        }
        private void RenderEditModeControls(BocDateTimeValueRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            var formatter   = renderingContext.Control.DateTimeFormatter;
            var dateTextBox = new RenderOnlyTextBox {
                ID = renderingContext.Control.GetDateValueName(), ClientIDMode = ClientIDMode.Static
            };

            Initialize(renderingContext, dateTextBox, renderingContext.Control.DateTextBoxStyle, formatter.GetDateMaxLength());
            dateTextBox.Text = renderingContext.Control.Value.HasValue ? formatter.FormatDateValue(renderingContext.Control.Value.Value) : renderingContext.Control.DateString;
            dateTextBox.Page = renderingContext.Control.Page.WrappedInstance;

            var timeTextBox = new RenderOnlyTextBox {
                ID = renderingContext.Control.GetTimeValueName(), ClientIDMode = ClientIDMode.Static
            };
            var showSeconds = renderingContext.Control.ShowSeconds;

            Initialize(renderingContext, timeTextBox, renderingContext.Control.TimeTextBoxStyle, formatter.GetTimeMaxLength(showSeconds));
            timeTextBox.Text = renderingContext.Control.Value.HasValue ? formatter.FormatTimeValue(renderingContext.Control.Value.Value, showSeconds) : renderingContext.Control.TimeString;
            timeTextBox.Page = renderingContext.Control.Page.WrappedInstance;

            var datePickerButton = renderingContext.Control.DatePickerButton;

            datePickerButton.AlternateText = renderingContext.Control.GetDatePickerText();
            datePickerButton.IsDesignMode  = renderingContext.Control.IsDesignMode;

            RenderTableBeginTag(renderingContext, dateTextBox, timeTextBox); // Begin table
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr);    // Begin tr

            bool hasDateField = false;
            bool hasTimeField = false;

            switch (renderingContext.Control.ActualValueType)
            {
            case BocDateTimeValueType.Date:
                hasDateField = true;
                break;

            case BocDateTimeValueType.DateTime:
            case BocDateTimeValueType.Undefined:
                hasDateField = true;
                hasTimeField = true;
                break;
            }
            bool canScript     = DetermineClientScriptLevel(datePickerButton, renderingContext);
            bool hasDatePicker = hasDateField && canScript;

            int    dateTextBoxWidthPercentage = GetDateTextBoxWidthPercentage(renderingContext, hasDateField, hasTimeField);
            string dateTextBoxSize            = GetDateTextBoxSize(renderingContext, dateTextBoxWidthPercentage);
            string timeTextBoxSize            = GetTimeTextBoxSize(renderingContext, 100 - dateTextBoxWidthPercentage);

            RenderDateCell(renderingContext, hasDateField, dateTextBox, dateTextBoxSize);
            RenderDatePickerCell(renderingContext, hasDatePicker, datePickerButton);

            //HACK: Opera has problems with inline tables and may collapse contents unless a cell with width 0% is present
            InsertDummyCellForOpera(renderingContext, hasDatePicker);

            RenderTimeCell(renderingContext, hasDateField, hasTimeField, timeTextBox, timeTextBoxSize);

            renderingContext.Writer.RenderEndTag(); // End tr
            renderingContext.Writer.RenderEndTag(); // End table
        }