// Will apply style to literals if provided and determines if it should be visible internal static void ApplyStyleToLiteral(Literal literal, string text, Style style, bool setTableCellVisible) { // setTableCellVisible is used when we DO NOT make the whole table cell invisible, because in some layouts // it must exist for things to align correctly and its uncommon that this property will be empty anyway. bool visible = false; if (!String.IsNullOrEmpty(text)) { literal.Text = text; if (style != null) { LoginUtil.SetTableCellStyle(literal, style); } visible = true; } if (setTableCellVisible) { LoginUtil.SetTableCellVisible(literal, visible); } else { literal.Visible = visible; } }
private int GetTemplateIndex() { if (!DesignMode && Page != null && Page.Request.IsAuthenticated) { IPrincipal user = LoginUtil.GetUser(this); int roleGroupIndex = -1; // Unlikely but possible for Page.Request.IsAuthenticated to be true and // user to be null. if (user != null) { roleGroupIndex = RoleGroups.GetMatchingRoleGroupInternal(user); } if (roleGroupIndex >= 0) { return(roleGroupIndex + roleGroupStartingIndex); } else { return(loggedInTemplateIndex); } } else { return(anonymousTemplateIndex); } }
protected internal virtual string ModifiedOuterTableStylePropertyName() { if (this.BorderPadding != 1) { return("BorderPadding"); } return(LoginUtil.ModifiedOuterTableBasicStylePropertyName(this.Owner)); }
/// <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); } }
private int GetTemplateIndex() { if ((base.DesignMode || (this.Page == null)) || !this.Page.Request.IsAuthenticated) { return(0); } IPrincipal user = LoginUtil.GetUser(this); int matchingRoleGroupInternal = -1; if (user != null) { matchingRoleGroupInternal = this.RoleGroups.GetMatchingRoleGroupInternal(user); } if (matchingRoleGroupInternal >= 0) { return(matchingRoleGroupInternal + 2); } return(1); }
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); } }