Пример #1
0
            /// <devdoc>
            ///     Renders the template contents.  The default template is rendered directly since it is already a table.
            ///     A user template is rendered inside a table with one row and one cell.
            ///     User a single-cell table instead of a <div>, since the <div> always spans the full width of its
            ///     containing element, while a <table> sets width to contents.
            /// </devdoc>
            protected internal sealed override void Render(HtmlTextWriter writer)
            {
                if (!RenderOuterTable)
                {
                    string propertyName = ModifiedOuterTableStylePropertyName();
                    if (!string.IsNullOrEmpty(propertyName))
                    {
                        throw new InvalidOperationException(SR.GetString(SR.IRenderOuterTableControl_CannotSetStyleWhenDisableRenderOuterTable,
                                                                         propertyName, _owner.GetType().Name, _owner.ID));
                    }
                }

                if (UsingDefaultTemplate)
                {
                    // If we are converting to template, then do not apply the base attributes or ControlStyle
                    // to the BorderTable or LayoutTable.  These will be rendered around the template contents
                    // at runtime.
                    if (!ConvertingToTemplate)
                    {
                        BorderTable.CopyBaseAttributes(this);
                        if (ControlStyleCreated)
                        {
                            // I assume we apply the BorderStyles and Font/ForeColor separately to make the rendering
                            // work in IE Quirks mode.  If we only wanted to support Standards mode, we could probably
                            // apply all the styles to the BorderTable.  I'm not changing this for Whidbey RTM
                            // since it is high-risk.
                            LoginUtil.CopyBorderStyles(BorderTable, ControlStyle);
                            LoginUtil.CopyStyleToInnerControl(LayoutTable, ControlStyle);
                        }
                    }

                    // Need to set height and width even when converting to template, to force the inner
                    // LayoutTable to fill the contents of the outer control.
                    LayoutTable.Height = Height;
                    LayoutTable.Width  = Width;

                    if (RenderOuterTable)
                    {
                        RenderContents(writer);
                    }
                    else
                    {
                        // just render what would have been rendered in the outer table's single cell
                        ControlCollection controlsInCell = BorderTable.Rows[0].Cells[0].Controls;
                        RenderControls(writer, controlsInCell);
                    }
                }
                else
                {
                    RenderContentsInUnitTable(writer);
                }
            }
Пример #2
0
 protected internal sealed override void Render(HtmlTextWriter writer)
 {
     if (!this.RenderOuterTable)
     {
         string str = this.ModifiedOuterTableStylePropertyName();
         if (!string.IsNullOrEmpty(str))
         {
             throw new InvalidOperationException(System.Web.SR.GetString("IRenderOuterTableControl_CannotSetStyleWhenDisableRenderOuterTable", new object[] { str, this._owner.GetType().Name, this._owner.ID }));
         }
     }
     if (this.UsingDefaultTemplate)
     {
         if (!this.ConvertingToTemplate)
         {
             this.BorderTable.CopyBaseAttributes(this);
             if (base.ControlStyleCreated)
             {
                 LoginUtil.CopyBorderStyles(this.BorderTable, base.ControlStyle);
                 LoginUtil.CopyStyleToInnerControl(this.LayoutTable, base.ControlStyle);
             }
         }
         this.LayoutTable.Height = this.Height;
         this.LayoutTable.Width  = this.Width;
         if (this.RenderOuterTable)
         {
             this.RenderContents(writer);
         }
         else
         {
             ControlCollection controls = this.BorderTable.Rows[0].Cells[0].Controls;
             LoginUtil.GenericContainer <ControlType> .RenderControls(writer, controls);
         }
     }
     else
     {
         this.RenderContentsInUnitTable(writer);
     }
 }