/// <summary> /// This method create a selector based on the parameters. /// </summary> /// <param name="output">The HtmlTextWriter to write.</param> /// <param name="suffix">The suffix to use to identify the selector with the LoadPostData method.</param> /// <param name="style">The style class to use.</param> /// <param name="onchange">The value of the OnChange attribute of the selector to use with the client side validator.</param> /// <param name="min">The minimum value of the selector.</param> /// <param name="max">The maximum value of the selector.</param> /// <param name="padding">The number of chars to use with padding.</param> /// <param name="selectedValue">The selected value.</param> private void WriteSelector(HtmlTextWriter output, string suffix, System.Web.UI.WebControls.Style style, string onchange, int min, int max, int padding, int selectedValue) { // Some variable we will use int index; // Check if the actual year value can be displayed in the selector if (selectedValue < min || selectedValue > max) { throw new Exception("The year value (" + Date.Year.ToString() + ") of the Date property is greater than the maximum (" + max.ToString() + ") or less than the minimum (" + min.ToString() + "). Please adjust values or set AutoAdjust property to true."); } // Write the selector output.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + suffix); // Render the validation action code only if needed if (_renderUplevel && onchange != null) { output.AddAttribute(HtmlTextWriterAttribute.Onchange, onchange); } // Add the styles to the selector after the merge with the base style. style.MergeWith(_baseStyle); style.AddAttributesToRender(output); output.RenderBeginTag(HtmlTextWriterTag.Select); // Write the option tags for (index = min; index <= max; index++) { output.AddAttribute(HtmlTextWriterAttribute.Value, index.ToString()); // Set the selected value if (index == selectedValue) { output.AddAttribute(HtmlTextWriterAttribute.Selected, null); } output.RenderBeginTag(HtmlTextWriterTag.Option); if (suffix == "_month" && !_monthNamesDisabled) { output.InnerWriter.Write(_months[index - 1]); } else { output.InnerWriter.Write(index.ToString().PadLeft(padding, '0')); } output.RenderEndTag(); } // Write the selector end tag output.RenderEndTag(); }
private void WriteSelector(HtmlTextWriter output, string suffix, int min, int max, int padding, int selectedValue, System.Web.UI.WebControls.Style selectorStyle, string[] months, bool show, bool relative) { int index; selectorStyle.AddAttributesToRender(output); if (!show) { if (relative) { output.AddStyleAttribute("position", "relative"); } else { output.AddStyleAttribute("position", "absolute"); } output.AddStyleAttribute("visibility", "hidden"); } output.RenderBeginTag(HtmlTextWriterTag.Select); for (index = min; index <= max; index++) { output.AddAttribute(HtmlTextWriterAttribute.Value, index.ToString()); if (index == selectedValue) { output.AddAttribute(HtmlTextWriterAttribute.Selected, null); } output.RenderBeginTag(HtmlTextWriterTag.Option); if (suffix.StartsWith("_month")) { output.InnerWriter.Write(months[index - 1]); } else if (suffix == "_meridiem") { output.InnerWriter.Write((index == 0 ? "AM" : "PM")); } else { output.InnerWriter.Write(index.ToString().PadLeft(padding, '0')); } output.RenderEndTag(); } output.RenderEndTag(); }
protected virtual void AddAttributesToRender(HtmlTextWriter writer) { #if NET_4_0 RenderDisabled(writer); #endif if (ID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); } #if !NET_4_0 RenderDisabled(writer); #endif if (AccessKey != string.Empty) { writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, AccessKey); } if (ToolTip != string.Empty) { writer.AddAttribute(HtmlTextWriterAttribute.Title, ToolTip); } if (TabIndex != 0) { writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString()); } if (style != null && !style.IsEmpty) { #if NET_2_0 //unbelievable, but see WebControlTest.RenderBeginTag_BorderWidth_xxx if (TagKey == HtmlTextWriterTag.Span) { AddDisplayStyleAttribute(writer); } #endif style.AddAttributesToRender(writer, this); } if (attributes != null) { foreach (string s in attributes.Keys) { writer.AddAttribute(s, attributes [s]); } } }
protected override void RenderHeader(HtmlTextWriter writer) { writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); TitleStyle headerStyle = base.HeaderStyle; if (!headerStyle.IsEmpty) { Style style2 = new Style(); if (!headerStyle.ForeColor.IsEmpty) { style2.ForeColor = headerStyle.ForeColor; } style2.Font.CopyFrom(headerStyle.Font); if (!headerStyle.Font.Size.IsEmpty) { style2.Font.Size = new FontUnit(new Unit(100.0, UnitType.Percentage)); } if (!style2.IsEmpty) { style2.AddAttributesToRender(writer, this); } } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); HorizontalAlign horizontalAlign = headerStyle.HorizontalAlign; if (horizontalAlign != HorizontalAlign.NotSet) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddAttribute(HtmlTextWriterAttribute.Align, converter.ConvertToString(horizontalAlign)); } writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(this.DisplayTitle); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); }
public static void Style_AddRegisteredCssClassAttribute_Load (Page p) { StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); Style s = new Style (); s.CssClass = "MyClass"; s.BackColor = Color.AliceBlue; s.AddAttributesToRender (tw); tw.RenderBeginTag ("span"); tw.RenderEndTag (); Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass\""), "AddRegisteredCssClassAttribute#1"); Assert.AreEqual (true, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#2"); sw = new StringWriter (); tw = new HtmlTextWriter (sw); s = new Style (); s.BackColor = Color.AliceBlue; p.Header.StyleSheet.RegisterStyle (s, p); s.AddAttributesToRender (tw); tw.RenderBeginTag ("span"); tw.RenderEndTag (); Assert.AreEqual (true, sw.ToString ().Contains ("class"), "AddRegisteredCssClassAttribute#3"); Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#4"); sw = new StringWriter (); tw = new HtmlTextWriter (sw); s = new Style (); s.BackColor = Color.AliceBlue; s.CssClass = "MyClass"; p.Header.StyleSheet.RegisterStyle (s, p); s.AddAttributesToRender (tw); tw.RenderBeginTag ("span"); tw.RenderEndTag (); Assert.AreEqual (sw.ToString ().LastIndexOf ("class"), sw.ToString ().IndexOf ("class"), "AddRegisteredCssClassAttribute#5"); Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#6"); Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass "), "AddRegisteredCssClassAttribute#7"); s = new Style (); p.Header.StyleSheet.RegisterStyle (s, p); Assert.AreEqual (false, s.IsEmpty, "AddRegisteredCssClassAttribute#8"); }
void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool notLast, bool isFirst) { bool displayChildren = DisplayChildren (item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= StaticDisplayLevels); bool isDynamicItem = IsDynamicItem (item); bool vertical = (Orientation == Orientation.Vertical) || isDynamicItem; Unit itemSpacing = GetItemSpacing (item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) RenderMenuItemSpacing (writer, itemSpacing, vertical); if(!String.IsNullOrEmpty(item.ToolTip)) writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip); if (vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute ("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + ClientID + "','" + item.Path + "')"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')"); } writer.RenderBeginTag (HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem && DynamicTopSeparatorImageUrl != "") { writer.AddAttribute ("src", ResolveClientUrl (DynamicTopSeparatorImageUrl)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG } else if (!isDynamicItem && StaticTopSeparatorImageUrl != "") { writer.AddAttribute ("src", ResolveClientUrl (StaticTopSeparatorImageUrl)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG } // Menu item box MenuItemStyle style = new MenuItemStyle (); if (Page.Header != null) { // styles are registered if (!isDynamicItem && staticMenuItemStyle != null) { AddCssClass (style, staticMenuItemStyle.CssClass); AddCssClass (style, staticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && dynamicMenuItemStyle != null) { AddCssClass (style, dynamicMenuItemStyle.CssClass); AddCssClass (style, dynamicMenuItemStyle.RegisteredCssClass); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { AddCssClass (style, levelMenuItemStyles [item.Depth].CssClass); AddCssClass (style, levelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { AddCssClass (style, staticSelectedStyle.CssClass); AddCssClass (style, staticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && dynamicSelectedStyle != null) { AddCssClass (style, dynamicSelectedStyle.CssClass); AddCssClass (style, dynamicSelectedStyle.RegisteredCssClass); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { AddCssClass (style, levelSelectedStyles [item.Depth].CssClass); AddCssClass (style, levelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && staticMenuItemStyle != null) { style.CopyFrom (staticMenuItemStyle); } if (isDynamicItem && dynamicMenuItemStyle != null) { style.CopyFrom (dynamicMenuItemStyle); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { style.CopyFrom (levelMenuItemStyles [item.Depth]); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { style.CopyFrom (staticSelectedStyle); } if (isDynamicItem && dynamicSelectedStyle != null) { style.CopyFrom (dynamicSelectedStyle); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { style.CopyFrom (levelSelectedStyles [item.Depth]); } } } style.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (item, "i")); writer.AddAttribute ("cellpadding", "0", false); writer.AddAttribute ("cellspacing", "0", false); writer.AddAttribute ("border", "0", false); writer.AddAttribute ("width", "100%", false); writer.RenderBeginTag (HtmlTextWriterTag.Table); writer.RenderBeginTag (HtmlTextWriterTag.Tr); // Menu item text if (vertical) writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%"); if (!ItemWrap) writer.AddStyleAttribute ("white-space", "nowrap"); writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderItemHref (writer, item); Style linkStyle = new Style (); if (Page.Header != null) { // styles are registered AddCssClass (linkStyle, ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && staticMenuItemStyle != null) { AddCssClass (linkStyle, staticMenuItemStyle.CssClass); AddCssClass (linkStyle, staticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && dynamicMenuItemStyle != null) { AddCssClass (linkStyle, dynamicMenuItemStyle.CssClass); AddCssClass (linkStyle, dynamicMenuItemLinkStyle.RegisteredCssClass); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { AddCssClass (linkStyle, levelMenuItemStyles [item.Depth].CssClass); AddCssClass (linkStyle, levelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { AddCssClass (linkStyle, staticSelectedStyle.CssClass); AddCssClass (linkStyle, staticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && dynamicSelectedStyle != null) { AddCssClass (linkStyle, dynamicSelectedStyle.CssClass); AddCssClass (linkStyle, dynamicSelectedLinkStyle.RegisteredCssClass); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { AddCssClass (linkStyle, levelSelectedStyles [item.Depth].CssClass); AddCssClass (linkStyle, levelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom (ControlLinkStyle); if (!isDynamicItem && staticMenuItemStyle != null) { linkStyle.CopyFrom (staticMenuItemLinkStyle); } if (isDynamicItem && dynamicMenuItemStyle != null) { linkStyle.CopyFrom (dynamicMenuItemLinkStyle); } if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) { linkStyle.CopyFrom (levelMenuItemLinkStyles [item.Depth]); } if (item == SelectedItem) { if (!isDynamicItem && staticSelectedStyle != null) { linkStyle.CopyFrom (staticSelectedLinkStyle); } if (isDynamicItem && dynamicSelectedStyle != null) { linkStyle.CopyFrom (dynamicSelectedLinkStyle); } if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) { linkStyle.CopyFrom (levelSelectedLinkStyles [item.Depth]); } } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (item, "l")); if (item.Depth > 0 && !isDynamicItem) { Unit indent = new Unit (StaticSubMenuIndent.Value * item.Depth, StaticSubMenuIndent.Type); writer.AddStyleAttribute ("margin-left", indent.ToString ()); } writer.RenderBeginTag (HtmlTextWriterTag.A); RenderItemContent (writer, item, isDynamicItem); writer.RenderEndTag (); // A writer.RenderEndTag (); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage (item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", ResolveClientUrl (popOutImage)); writer.AddAttribute ("border", "0"); string toolTip = String.Format (isDynamicItem ? DynamicPopOutImageTextFormatString : StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG writer.RenderEndTag (); // TD } } writer.RenderEndTag (); // TR writer.RenderEndTag (); // TABLE writer.RenderEndTag (); // TD if (!vertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute ("width", "3px"); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) separatorImg = DynamicBottomSeparatorImageUrl; else separatorImg = StaticBottomSeparatorImageUrl; } if (separatorImg.Length > 0) { if (!vertical) writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", ResolveClientUrl (separatorImg)); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG if (!vertical) writer.RenderEndTag (); // TD } if (vertical) writer.RenderEndTag (); // TR if (itemSpacing != Unit.Empty) RenderMenuItemSpacing (writer, itemSpacing, vertical); // Submenu if (displayChildren && !dynamicChildren) { if (vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("width", "100%"); RenderMenu (writer, item.ChildItems, Orientation == Orientation.Vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == StaticDisplayLevels) RenderDynamicMenu (writer, item.ChildItems); writer.RenderEndTag (); // TD if (vertical) writer.RenderEndTag (); // TR } }
protected internal override void Render(HtmlTextWriter writer) { this.AddAttributesToRender(writer); if (this.Page != null) { this.Page.VerifyRenderingInServerForm(this); } bool flag = false; if (!base.IsEnabled) { if (this.RenderingCompatibility < VersionUtil.Framework40) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); flag = true; } else if (!this.Enabled && !string.IsNullOrEmpty(WebControl.DisabledCssClass)) { if (string.IsNullOrEmpty(this.CssClass)) { base.ControlStyle.CssClass = WebControl.DisabledCssClass; } else { base.ControlStyle.CssClass = WebControl.DisabledCssClass + " " + this.CssClass; } flag = true; } } if (base.ControlStyleCreated) { Style controlStyle = base.ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); flag = true; } } string toolTip = this.ToolTip; if (toolTip.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, toolTip); flag = true; } string str2 = null; if (base.HasAttributes) { System.Web.UI.AttributeCollection attributes = base.Attributes; string str3 = attributes["value"]; if (str3 != null) { attributes.Remove("value"); } str2 = attributes["onclick"]; if (str2 != null) { str2 = Util.EnsureEndWithSemiColon(str2); attributes.Remove("onclick"); } if (attributes.Count != 0) { attributes.AddAttributes(writer); flag = true; } if (str3 != null) { attributes["value"] = str3; } } if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Span); } string text = this.Text; string clientID = this.ClientID; if (text.Length != 0) { if (this.TextAlign == System.Web.UI.WebControls.TextAlign.Left) { this.RenderLabel(writer, text, clientID); this.RenderInputTag(writer, clientID, str2); } else { this.RenderInputTag(writer, clientID, str2); this.RenderLabel(writer, text, clientID); } } else { this.RenderInputTag(writer, clientID, str2); } if (flag) { writer.RenderEndTag(); } }
public HtmlAttributeManager Style(Style style) { style.AddAttributesToRender(Writer); return this; }
protected override void RenderBody(HtmlTextWriter writer) { Orientation orientation = LayoutOrientation; if (DesignMode || (WebPartManager != null && (WebPartManager.DisplayMode.AllowPageDesign))) { if (_borderColor != Color.Empty || _borderStyle != BorderStyle.NotSet || _borderWidth != Unit.Empty) { Style s = new Style(); s.BorderColor = _borderColor; s.BorderStyle = _borderStyle; s.BorderWidth = _borderWidth; s.AddAttributesToRender(writer, this); } } RenderBodyTableBeginTag(writer); if (DesignMode) { RenderDesignerRegionBeginTag(writer, orientation); } if (orientation == Orientation.Horizontal) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } bool dragDropEnabled = DragDropEnabled; if (dragDropEnabled) { RenderDropCue(writer); } WebPartCollection webParts = WebParts; if (webParts == null || webParts.Count == 0) { RenderEmptyZoneBody(writer); } else { WebPartChrome chrome = WebPartChrome; foreach (WebPart webPart in webParts) { // Don't render anything visible for a minimized part if its effective frame // type dictates that a title bar will not be rendered. (VSWhidbey 77730) if (webPart.ChromeState == PartChromeState.Minimized) { PartChromeType chromeType = GetEffectiveChromeType(webPart); if (chromeType == PartChromeType.None || chromeType == PartChromeType.BorderOnly) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } } if (orientation == Orientation.Vertical) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else { // Mac IE needs height=100% set on <td> instead of <tr> writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); chrome.RenderWebPart(writer, webPart); writer.RenderEndTag(); // Td if (orientation == Orientation.Vertical) { writer.RenderEndTag(); // Tr } if (dragDropEnabled) { RenderDropCue(writer); } } if (orientation == Orientation.Vertical) { // Add an extra row with height of 100%, to [....] up any extra space // if the height of the zone is larger than its contents writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Mozilla renders padding on an empty TD without this attribute writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0"); // Mac IE needs height=100% set on <td> instead of <tr> writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } else { // Add an extra cell with width of 100%, to [....] up any extra space // if the width of the zone is larger than its contents. writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); // Mozilla renders padding on an empty TD without this attribute writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); // Td } } if (orientation == Orientation.Horizontal) { writer.RenderEndTag(); // Tr } if (DesignMode) { RenderDesignerRegionEndTag(writer); } RenderBodyTableEndTag(writer); }
public virtual void EnterStyle(Style style, HtmlTextWriterTag tag) { if (!style.IsEmpty || tag != HtmlTextWriterTag.Span) { style.AddAttributesToRender(this); RenderBeginTag(tag); } }
protected DateTime RenderDayRow(HtmlTextWriter writer, DateTime rowStart) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "dates"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); DateTime curDay = rowStart; for (int i = 0; i < 7; i++) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "day"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); if (this.ControlStyle != null) { System.Web.UI.WebControls.Style tdStyle = new Style(); tdStyle.BorderStyle = this.ControlStyle.BorderStyle; tdStyle.BorderColor = this.ControlStyle.BorderColor; tdStyle.BorderWidth = this.ControlStyle.BorderWidth; tdStyle.ForeColor = this.ControlStyle.ForeColor; tdStyle.BackColor = this.ControlStyle.BackColor; tdStyle.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); //LinkButton lnkDate = new LinkButton(); //lnkDate.ID = "lnkDate_" + curDay.ToString("yyyyMMdd"); //lnkDate.Text = curDay.Day.ToString(); //lnkDate.CssClass = "date"; //lnkDate.CommandName = "ShowDay"; //lnkDate.CommandArgument = curDay.ToString("yyyyMMdd"); //lnkDate.Command += new CommandEventHandler(this.lnkDate_OnCommand); //lnkDate.ApplyStyle((curDay.Month == this.dtCurMon.Month) ? this._curMonDateStyle : this._othMonDateStyle); //this.Controls.Add(lnkDate); LinkButton lnkDate = (LinkButton)this._lnkDates[curDay.ToString("yyyyMMdd")]; lnkDate.RenderControl(writer); writer.RenderEndTag(); curDay = curDay.AddDays(1); } writer.RenderEndTag(); // TR (date row) return curDay; }
/// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RenderHorizontalRepeater"]/*' /> /// <devdoc> /// </devdoc> private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout"); int itemCount = user.RepeatedItemCount; int totalColumns = repeatColumns; int currentColumn = 0; if (totalColumns == 0) { // 0 implies a complete horizontal repetition without any // column count constraints totalColumns = itemCount; } WebControl outerControl = null; bool tableLayout = false; switch (repeatLayout) { case RepeatLayout.Table: outerControl = new Table(); tableLayout = true; break; case RepeatLayout.Flow: outerControl = new WebControl(HtmlTextWriterTag.Span); break; } bool separators = user.HasSeparators; // use ClientID (and not ID) since we want to render out the fully qualified client id // even though this outer control will not be parented to the control hierarchy outerControl.ID = baseControl.ClientID; outerControl.CopyBaseAttributes(baseControl); outerControl.ApplyStyle(controlStyle); outerControl.RenderBeginTag(writer); if (user.HasHeader) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TD if ((totalColumns != 1) || separators) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Header, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Header, -1, this, writer); if (tableLayout) { // render end tag for TD writer.RenderEndTag(); // render end tag for TR writer.RenderEndTag(); } else { if (totalColumns < itemCount) { // we have multiple rows, so have a break between the header and first row. writer.WriteFullBeginTag("br"); } } } for (int i = 0; i < itemCount; i++) { if (tableLayout && (currentColumn == 0)) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } if (tableLayout) { // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Item, i); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Item, i, this, writer); if (tableLayout) { // render end tag for TD writer.RenderEndTag(); } if (separators && (i != (itemCount - 1))) { if (tableLayout) { Style style = user.GetItemStyle(ListItemType.Separator, i); if (style != null) { style.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Separator, i, this, writer); if (tableLayout) { writer.RenderEndTag(); } } currentColumn++; if ((currentColumn == totalColumns) || (i == itemCount - 1)) { if (tableLayout) { // End tag for TR writer.RenderEndTag(); } else { // write out the <br> after rows when there are multiple rows if (totalColumns < itemCount) { writer.WriteFullBeginTag("br"); } } currentColumn = 0; } } if (user.HasFooter) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if ((totalColumns != 1) || separators) { // add attributes to render for TD int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Footer, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (tableLayout) { // render end tag for TR and TD writer.RenderEndTag(); writer.RenderEndTag(); } } outerControl.RenderEndTag(writer); }
private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { int repeatedItemCount = user.RepeatedItemCount; int repeatColumns = this.repeatColumns; int num3 = 0; if (repeatColumns == 0) { repeatColumns = repeatedItemCount; } WebControl control = null; bool flag = false; switch (this.repeatLayout) { case System.Web.UI.WebControls.RepeatLayout.Table: control = new Table(); if (this.Caption.Length != 0) { ((Table)control).Caption = this.Caption; ((Table)control).CaptionAlign = this.CaptionAlign; } flag = true; break; case System.Web.UI.WebControls.RepeatLayout.Flow: control = new WebControl(HtmlTextWriterTag.Span); break; } bool hasSeparators = user.HasSeparators; control.ID = baseControl.ClientID; control.CopyBaseAttributes(baseControl); control.ApplyStyle(controlStyle); control.RenderBeginTag(writer); if (user.HasHeader) { if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if ((repeatColumns != 1) || hasSeparators) { int num4 = repeatColumns; if (hasSeparators) { num4 += repeatColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num4.ToString(NumberFormatInfo.InvariantInfo)); } if (this.useAccessibleHeader) { writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col"); } Style itemStyle = user.GetItemStyle(ListItemType.Header, -1); if (itemStyle != null) { itemStyle.AddAttributesToRender(writer); } if (this.useAccessibleHeader) { writer.RenderBeginTag(HtmlTextWriterTag.Th); } else { writer.RenderBeginTag(HtmlTextWriterTag.Td); } } user.RenderItem(ListItemType.Header, -1, this, writer); if (flag) { writer.RenderEndTag(); writer.RenderEndTag(); } else if (repeatColumns < repeatedItemCount) { if (this.EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } for (int i = 0; i < repeatedItemCount; i++) { if (flag && (num3 == 0)) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } if (flag) { Style style2 = user.GetItemStyle(ListItemType.Item, i); if (style2 != null) { style2.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Item, i, this, writer); if (flag) { writer.RenderEndTag(); } if (hasSeparators && (i != (repeatedItemCount - 1))) { if (flag) { Style style3 = user.GetItemStyle(ListItemType.Separator, i); if (style3 != null) { style3.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Separator, i, this, writer); if (flag) { writer.RenderEndTag(); } } num3++; if (flag && (i == (repeatedItemCount - 1))) { int num6 = repeatColumns - num3; if (hasSeparators) { int num7 = (num6 * 2) + 1; if (num7 > num6) { num6 = num7; } } for (int j = 0; j < num6; j++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } if ((num3 == repeatColumns) || (i == (repeatedItemCount - 1))) { if (flag) { writer.RenderEndTag(); } else if (repeatColumns < repeatedItemCount) { if (this.EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } num3 = 0; } } if (user.HasFooter) { if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if ((repeatColumns != 1) || hasSeparators) { int num9 = repeatColumns; if (hasSeparators) { num9 += repeatColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num9.ToString(NumberFormatInfo.InvariantInfo)); } Style style4 = user.GetItemStyle(ListItemType.Footer, -1); if (style4 != null) { style4.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (flag) { writer.RenderEndTag(); writer.RenderEndTag(); } } control.RenderEndTag(writer); }
/// <summary> /// This method create a selector based on the parameters. /// </summary> /// <param name="output">The HtmlTextWriter to write.</param> /// <param name="suffix">The suffix to use to identify the selector with the LoadPostData method.</param> /// <param name="style">The style class to use.</param> /// <param name="onchange">The value of the OnChange attribute of the selector to use with the client side validator.</param> /// <param name="min">The minimum value of the selector.</param> /// <param name="max">The maximum value of the selector.</param> /// <param name="padding">The number of chars to use with padding.</param> /// <param name="selectedValue">The selected value.</param> private void WriteSelector(HtmlTextWriter output, string suffix, System.Web.UI.WebControls.Style style, string onchange, int min, int max, int padding, int selectedValue, short tabIndex) { // Check if the actual year value can be displayed in the selector if (selectedValue < min || selectedValue > max) { throw new Exception("The year value (" + Date.Year.ToString() + ") of the Date property is greater than the maximum (" + max.ToString() + ") or less than the minimum (" + min.ToString() + "). Please adjust values or set AutoAdjust property to true."); } // Some variable we will use int index; output.WriteBeginTag("select"); if (!this.Enabled) { output.WriteAttribute("disabled", "disabled"); } output.WriteAttribute("name", UniqueID + suffix); if (_renderUplevel && onchange != null) { output.WriteAttribute("onchange", onchange); } output.WriteLine(HtmlTextWriter.TagRightChar); // Add the styles to the selector after the merge with the base style. style.MergeWith(_baseStyle); style.AddAttributesToRender(output); // // Write Tab Index // if(tabIndex != 0) // output.AddAttribute("tabindex", tabIndex.ToString()); output.Indent++; // Write the option tags for (index = min; index <= max; index++) { output.WriteBeginTag("option"); output.WriteAttribute("value", index.ToString()); // Set the selected value if (index == selectedValue) { output.WriteAttribute("selected", null); } output.Write(HtmlTextWriter.TagRightChar); if (suffix == "_month" && !_monthNamesDisabled) { output.Write(_months[index - 1]); } else { output.Write(index.ToString().PadLeft(padding, '0')); } output.WriteEndTag("option"); output.WriteLine(); } output.Indent--; // Write the selector end tag output.WriteEndTag("select"); }
protected override void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; string clientID = oc.ClientID; bool displayChildren = owner.DisplayChildren (item); bool isDynamicItem = IsDynamicItem (owner, item); int itemLevel = item.Depth + 1; string str; writer.RenderBeginTag (HtmlTextWriterTag.Li); if (isDynamicItem) RenderSeparatorImage (owner, writer, oc.DynamicTopSeparatorImageUrl, true); else RenderSeparatorImage (owner, writer, oc.StaticTopSeparatorImageUrl, true); var linkStyle = new Style (); if (displayChildren && (isDynamicItem || itemLevel >= oc.StaticDisplayLevels)) AddCssClass (linkStyle, isDynamicItem && haveDynamicPopOut ? "popout-dynamic" : "popout"); AddCssClass (linkStyle, "level" + itemLevel); MenuItemStyleCollection levelStyles = oc.LevelMenuItemStyles; if (levelStyles != null && levelStyles.Count >= itemLevel) { MenuItemStyle style = levelStyles [itemLevel - 1]; string cssClass = style.CssClass; if (!String.IsNullOrEmpty (cssClass)) AddCssClass (linkStyle, cssClass); } if (owner.SelectedItem == item) AddCssClass (linkStyle, "selected"); str = item.ToolTip; if (!String.IsNullOrEmpty (str)) writer.AddAttribute ("title", str); linkStyle.AddAttributesToRender (writer); RenderItemHref (owner, writer, item); writer.RenderBeginTag (HtmlTextWriterTag.A); owner.RenderItemContent (writer, item, isDynamicItem); writer.RenderEndTag (); str = item.SeparatorImageUrl; if (String.IsNullOrEmpty (str)) { if (isDynamicItem) str = oc.DynamicBottomSeparatorImageUrl; else str = oc.StaticBottomSeparatorImageUrl; } RenderSeparatorImage (owner, writer, str, true); // if (itemLevel == 1) // writer.RenderEndTag (); // </li> if (displayChildren) owner.RenderMenu (writer, item.ChildItems, vertical, isDynamicItem, itemLevel, notLast); if (itemLevel > 1) writer.RenderEndTag (); // </li> }
protected void RenderEmptyEvent(HtmlTextWriter writer) { if (this.ControlStyle != null) { System.Web.UI.WebControls.Style tdStyle = new Style(); tdStyle.BorderStyle = this.ControlStyle.BorderStyle; tdStyle.BorderColor = this.ControlStyle.BorderColor; tdStyle.BorderWidth = this.ControlStyle.BorderWidth; tdStyle.ForeColor = this.ControlStyle.ForeColor; tdStyle.BackColor = this.ControlStyle.BackColor; tdStyle.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "NoEvent"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.Write(" "); writer.RenderEndTag(); writer.RenderEndTag(); }
protected void RenderEventRow(HtmlTextWriter writer, DateTime rowStart) { DateTime rowEnd = rowStart.Date.AddDays(6); writer.AddAttribute(HtmlTextWriterAttribute.Class, "events"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); CalendarEvent[] events = this._provider.GetEvents(this.DisplayUserKey, rowStart.Date, rowEnd.Date); if (events.Length == 0) { for (int i = 0; i < 7; i++) this.RenderEmptyEvent(writer); } else { Style eventTextStyle = new Style(); eventTextStyle.MergeWith(this._eventStyle); eventTextStyle.BorderStyle = BorderStyle.None; List<CalendarEvent> unrenderedEvents = new List<CalendarEvent>(events); DateTime curDay = rowStart; while (unrenderedEvents.Count > 0) { // Doing the event this way, lets us put multiple events on the same // row, so long as they don't "interfere" with each other. CalendarEvent curEv = null; if (curDay.Date == rowStart.Date) // Make sure that we only allow events to occured before the // "current" date if we're on the first cell in the row. curEv = unrenderedEvents.Where(e => e.EventStartDate.Date <= curDay.Date).FirstOrDefault(); else curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault(); while (curEv == null && curDay.Date <= rowEnd.Date) { this.RenderEmptyEvent(writer); curDay = curDay.AddDays(1); curEv = unrenderedEvents.Where(e => e.EventStartDate.Date == curDay.Date).FirstOrDefault(); } if (curEv == null) { // If we still have no current event at this point, end this row, // start a new one, and let the search start over. curDay = rowStart; writer.RenderEndTag(); // TR (event row) writer.AddAttribute(HtmlTextWriterAttribute.Class, "events"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else { // Now, we write the actual event. int eventDays = curEv.EventEndDate.Date <= rowEnd.Date ? (int)System.Math.Ceiling(curEv.EventEndDate.Subtract(curDay).TotalDays) : (int)System.Math.Ceiling(rowEnd.Subtract(curDay).TotalDays) + 1; if (eventDays > 1) writer.AddAttribute(HtmlTextWriterAttribute.Colspan, eventDays.ToString()); if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd) writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid"); else if (curEv.EventStartDate < rowStart) writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd"); else if (curEv.EventEndDate > rowEnd) writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart"); else writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull"); if (this.ControlStyle != null) { System.Web.UI.WebControls.Style tdStyle = new Style(); tdStyle.BorderStyle = this.ControlStyle.BorderStyle; tdStyle.BorderColor = this.ControlStyle.BorderColor; tdStyle.BorderWidth = this.ControlStyle.BorderWidth; tdStyle.ForeColor = this.ControlStyle.ForeColor; tdStyle.BackColor = this.ControlStyle.BackColor; tdStyle.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); //if (curEv.EventStartDate < rowStart && curEv.EventEndDate > rowEnd) // writer.AddAttribute(HtmlTextWriterAttribute.Class, "evMid"); //else if (curEv.EventStartDate < rowStart) // writer.AddAttribute(HtmlTextWriterAttribute.Class, "evEnd"); //else if (curEv.EventEndDate > rowEnd) // writer.AddAttribute(HtmlTextWriterAttribute.Class, "evStart"); //else // writer.AddAttribute(HtmlTextWriterAttribute.Class, "evFull"); this._eventStyle.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.Div); LinkButton lnkEvent = new LinkButton(); lnkEvent.ID = "lnkEvent_" + curEv.ProviderEventKey + "_" + curDay.ToString("yyyyMMdd"); lnkEvent.Text = (curEv.EventStartDate.Date == curDay.Date) ? string.Format("{0} {1}", curEv.EventStartDate.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortTimePattern), curEv.Subject) : string.Format("<< {0}", curEv.Subject); lnkEvent.ApplyStyle(eventTextStyle); lnkEvent.CommandName = "ShowEvent"; lnkEvent.CommandArgument = curEv.ProviderEventKey.ToString(); lnkEvent.Command += new CommandEventHandler(this.lnkEvent_Command); this.Controls.Add(lnkEvent); lnkEvent.RenderControl(writer); writer.RenderEndTag(); // DIV writer.RenderEndTag(); // TD unrenderedEvents.Remove(curEv); curDay = curEv.EventEndDate.AddDays(1); } } while (curDay.Date <= rowEnd.Date) { // "Fill" any remaining days on this row. this.RenderEmptyEvent(writer); curDay = curDay.AddDays(1); } } writer.RenderEndTag(); // TR (event row) }
protected override void RenderMenuItem(HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; bool displayChildren = owner.DisplayChildren(item); bool isDynamicItem = IsDynamicItem(owner, item); int itemLevel = item.Depth + 1; string str; writer.RenderBeginTag(HtmlTextWriterTag.Li); if (isDynamicItem) { RenderSeparatorImage(owner, writer, oc.DynamicTopSeparatorImageUrl, true); } else { RenderSeparatorImage(owner, writer, oc.StaticTopSeparatorImageUrl, true); } var linkStyle = new Style(); if (displayChildren && (isDynamicItem || itemLevel >= oc.StaticDisplayLevels)) { AddCssClass(linkStyle, isDynamicItem && haveDynamicPopOut ? "popout-dynamic" : "popout"); } AddCssClass(linkStyle, "level" + itemLevel); MenuItemStyleCollection levelStyles = oc.LevelMenuItemStyles; if (levelStyles != null && levelStyles.Count >= itemLevel) { MenuItemStyle style = levelStyles [itemLevel - 1]; string cssClass = style.CssClass; if (!String.IsNullOrEmpty(cssClass)) { AddCssClass(linkStyle, cssClass); } } if (owner.SelectedItem == item) { AddCssClass(linkStyle, "selected"); } str = item.ToolTip; if (!String.IsNullOrEmpty(str)) { writer.AddAttribute("title", str); } linkStyle.AddAttributesToRender(writer); RenderItemHref(owner, writer, item); writer.RenderBeginTag(HtmlTextWriterTag.A); owner.RenderItemContent(writer, item, isDynamicItem); writer.RenderEndTag(); str = item.SeparatorImageUrl; if (String.IsNullOrEmpty(str)) { if (isDynamicItem) { str = oc.DynamicBottomSeparatorImageUrl; } else { str = oc.StaticBottomSeparatorImageUrl; } } RenderSeparatorImage(owner, writer, str, true); // if (itemLevel == 1) // writer.RenderEndTag (); // </li> if (displayChildren) { owner.RenderMenu(writer, item.ChildItems, vertical, isDynamicItem, itemLevel, notLast); } if (itemLevel > 0) { writer.RenderEndTag(); // </li> } }
void AddNodeLinkStyle (HtmlTextWriter writer, TreeNode node, int level, bool nodeIsSelected) { Style style = new Style (); #if NET_4_0 bool addBorderStyle = false; #endif if (Page.Header != null) { // styles are registered style.AddCssClass (ControlLinkStyle.RegisteredCssClass); if (nodeStyle != null) { style.AddCssClass (nodeLinkStyle.CssClass); style.AddCssClass (nodeLinkStyle.RegisteredCssClass); } if (levelLinkStyles != null && levelLinkStyles.Count > level) { style.AddCssClass (levelLinkStyles [level].CssClass); style.AddCssClass (levelLinkStyles [level].RegisteredCssClass); #if NET_4_0 addBorderStyle = true; #endif } if (node.IsLeafNode) { if (leafNodeStyle != null) { style.AddCssClass (leafNodeLinkStyle.CssClass); style.AddCssClass (leafNodeLinkStyle.RegisteredCssClass); } } else if (node.IsRootNode) { if (rootNodeStyle != null) { style.AddCssClass (rootNodeLinkStyle.CssClass); style.AddCssClass (rootNodeLinkStyle.RegisteredCssClass); } } else if (node.IsParentNode) { if (parentNodeStyle != null) { style.AddCssClass (parentNodeLinkStyle.CssClass); style.AddCssClass (parentNodeLinkStyle.RegisteredCssClass); } } if (nodeIsSelected) { style.AddCssClass (selectedNodeLinkStyle.CssClass); style.AddCssClass (selectedNodeLinkStyle.RegisteredCssClass); } } else { // styles are not registered style.CopyFrom (ControlLinkStyle); if (nodeStyle != null) style.CopyFrom (nodeLinkStyle); if (levelLinkStyles != null && levelLinkStyles.Count > level) { style.CopyFrom (levelLinkStyles [level]); #if NET_4_0 addBorderStyle = true; #endif } if (node.IsLeafNode) { if (node.IsLeafNode && leafNodeStyle != null) style.CopyFrom (leafNodeLinkStyle); } else if (node.IsRootNode) { if (node.IsRootNode && rootNodeStyle != null) style.CopyFrom (rootNodeLinkStyle); } else if (node.IsParentNode) { if (node.IsParentNode && parentNodeStyle != null) style.CopyFrom (parentNodeLinkStyle); } if (nodeIsSelected) style.CopyFrom (selectedNodeLinkStyle); style.AlwaysRenderTextDecoration = true; } #if NET_4_0 if (addBorderStyle) { // This appears not to come from any style. Instead, it's added // whenever a level style is present. writer.AddStyleAttribute (HtmlTextWriterStyle.BorderStyle, "none"); writer.AddStyleAttribute (HtmlTextWriterStyle.FontSize, "1em"); } #endif style.AddAttributesToRender (writer); }
void AddNodeLinkStyle (HtmlTextWriter writer, TreeNode node, int level, bool nodeIsSelected) { Style style = new Style (); if (Page.Header != null) { // styles are registered style.AddCssClass (ControlLinkStyle.RegisteredCssClass); if (nodeStyle != null) { style.AddCssClass (nodeLinkStyle.CssClass); style.AddCssClass (nodeLinkStyle.RegisteredCssClass); } if (levelLinkStyles != null && levelLinkStyles.Count > level) { style.AddCssClass (levelLinkStyles [level].CssClass); style.AddCssClass (levelLinkStyles [level].RegisteredCssClass); } if (node.IsLeafNode) { if (leafNodeStyle != null) { style.AddCssClass (leafNodeLinkStyle.CssClass); style.AddCssClass (leafNodeLinkStyle.RegisteredCssClass); } } else if (node.IsRootNode) { if (rootNodeStyle != null) { style.AddCssClass (rootNodeLinkStyle.CssClass); style.AddCssClass (rootNodeLinkStyle.RegisteredCssClass); } } else if (node.IsParentNode) { if (parentNodeStyle != null) { style.AddCssClass (parentNodeLinkStyle.CssClass); style.AddCssClass (parentNodeLinkStyle.RegisteredCssClass); } } if (nodeIsSelected) { style.AddCssClass (selectedNodeLinkStyle.CssClass); style.AddCssClass (selectedNodeLinkStyle.RegisteredCssClass); } } else { // styles are not registered style.CopyFrom (ControlLinkStyle); if (nodeStyle != null) style.CopyFrom (nodeLinkStyle); if (levelLinkStyles != null && levelLinkStyles.Count > level) style.CopyFrom (levelLinkStyles [level]); if (node.IsLeafNode) { if (node.IsLeafNode && leafNodeStyle != null) { style.CopyFrom (leafNodeLinkStyle); } } else if (node.IsRootNode) { if (node.IsRootNode && rootNodeStyle != null) { style.CopyFrom (rootNodeLinkStyle); } } else if (node.IsParentNode) { if (node.IsParentNode && parentNodeStyle != null) { style.CopyFrom (parentNodeLinkStyle); } } if (nodeIsSelected) style.CopyFrom (selectedNodeLinkStyle); style.AlwaysRenderTextDecoration = true; } style.AddAttributesToRender (writer); }
private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { int repeatColumns; int num3; int num4; int repeatedItemCount = user.RepeatedItemCount; if ((this.repeatColumns == 0) || (this.repeatColumns == 1)) { repeatColumns = 1; num4 = 1; num3 = repeatedItemCount; } else { repeatColumns = this.repeatColumns; num3 = ((repeatedItemCount + this.repeatColumns) - 1) / this.repeatColumns; if ((num3 == 0) && (repeatedItemCount != 0)) { num3 = 1; } num4 = repeatedItemCount % repeatColumns; if (num4 == 0) { num4 = repeatColumns; } } WebControl control = null; bool flag = false; if (!this.outerTableImplied) { switch (this.repeatLayout) { case System.Web.UI.WebControls.RepeatLayout.Table: control = new Table(); if (this.Caption.Length != 0) { ((Table)control).Caption = this.Caption; ((Table)control).CaptionAlign = this.CaptionAlign; } flag = true; break; case System.Web.UI.WebControls.RepeatLayout.Flow: control = new WebControl(HtmlTextWriterTag.Span); break; case System.Web.UI.WebControls.RepeatLayout.UnorderedList: control = new WebControl(HtmlTextWriterTag.Ul); break; case System.Web.UI.WebControls.RepeatLayout.OrderedList: control = new WebControl(HtmlTextWriterTag.Ol); break; } } bool hasSeparators = user.HasSeparators; if (control != null) { control.ID = baseControl.ClientID; control.CopyBaseAttributes(baseControl); control.ApplyStyle(controlStyle); control.RenderBeginTag(writer); } if (user.HasHeader) { if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (repeatColumns != 1) { int num5 = repeatColumns; if (hasSeparators) { num5 += repeatColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num5.ToString(NumberFormatInfo.InvariantInfo)); } if (this.useAccessibleHeader) { writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col"); } Style itemStyle = user.GetItemStyle(ListItemType.Header, -1); if (itemStyle != null) { itemStyle.AddAttributesToRender(writer); } if (this.useAccessibleHeader) { writer.RenderBeginTag(HtmlTextWriterTag.Th); } else { writer.RenderBeginTag(HtmlTextWriterTag.Td); } } user.RenderItem(ListItemType.Header, -1, this, writer); if (flag) { writer.RenderEndTag(); writer.RenderEndTag(); } else if (!this.outerTableImplied) { if (this.EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } int num6 = 0; for (int i = 0; i < num3; i++) { if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } int repeatIndex = i; for (int j = 0; j < repeatColumns; j++) { if (num6 >= repeatedItemCount) { break; } if (j != 0) { repeatIndex += num3; if ((j - 1) >= num4) { repeatIndex--; } } if (repeatIndex < repeatedItemCount) { num6++; if (flag) { Style style2 = user.GetItemStyle(ListItemType.Item, repeatIndex); if (style2 != null) { style2.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } if (this.IsListLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Li); } user.RenderItem(ListItemType.Item, repeatIndex, this, writer); if (this.IsListLayout) { writer.RenderEndTag(); writer.WriteLine(); } if (flag) { writer.RenderEndTag(); } if (hasSeparators) { if (repeatIndex != (repeatedItemCount - 1)) { if (repeatColumns == 1) { if (flag) { writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else if (!this.outerTableImplied) { if (this.EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } if (flag) { Style style3 = user.GetItemStyle(ListItemType.Separator, repeatIndex); if (style3 != null) { style3.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } if (repeatIndex < repeatedItemCount) { user.RenderItem(ListItemType.Separator, repeatIndex, this, writer); } if (flag) { writer.RenderEndTag(); } } else if (flag && (repeatColumns > 1)) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } } } if (flag) { if (i == (num3 - 1)) { int num10 = repeatColumns - num4; if (hasSeparators) { int num11 = num10 * 2; if (num11 >= num10) { num10 = num11; } } if (num10 != 0) { for (int k = 0; k < num10; k++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } } writer.RenderEndTag(); } else if (((i != (num3 - 1)) || user.HasFooter) && (!this.outerTableImplied && !this.IsListLayout)) { if (this.EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } if (user.HasFooter) { if (flag) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (repeatColumns != 1) { int num13 = repeatColumns; if (hasSeparators) { num13 += repeatColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num13.ToString(NumberFormatInfo.InvariantInfo)); } Style style4 = user.GetItemStyle(ListItemType.Footer, -1); if (style4 != null) { style4.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (flag) { writer.RenderEndTag(); writer.RenderEndTag(); } } if (control != null) { control.RenderEndTag(writer); } }
protected override void RenderHeader(HtmlTextWriter writer) { writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); TitleStyle headerStyle = base.HeaderStyle; if (!headerStyle.IsEmpty) { Style style2 = new Style(); if (!headerStyle.ForeColor.IsEmpty) { style2.ForeColor = headerStyle.ForeColor; } style2.Font.CopyFrom(headerStyle.Font); if (!headerStyle.Font.Size.IsEmpty) { style2.Font.Size = new FontUnit(new Unit(100.0, UnitType.Percentage)); } if (!style2.IsEmpty) { style2.AddAttributesToRender(writer, this); } } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); HorizontalAlign horizontalAlign = headerStyle.HorizontalAlign; if (horizontalAlign != HorizontalAlign.NotSet) { TypeConverter converter = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddAttribute(HtmlTextWriterAttribute.Align, converter.ConvertToString(horizontalAlign)); } writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(this.HeaderText); writer.RenderEndTag(); WebPartVerb headerCloseVerb = this.HeaderCloseVerb; if (headerCloseVerb.Visible) { writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); ZoneLinkButton button = new ZoneLinkButton(this, headerCloseVerb.EventArgument) { Text = headerCloseVerb.Text, ImageUrl = headerCloseVerb.ImageUrl, ToolTip = headerCloseVerb.Description, Enabled = headerCloseVerb.Enabled, Page = this.Page }; button.ApplyStyle(this.HeaderVerbStyle); button.RenderControl(writer); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); }
/// <internalonly/> /// <devdoc> /// <para>Displays the <see cref='System.Web.UI.WebControls.CheckBox'/> on the client.</para> /// </devdoc> protected internal override void Render(HtmlTextWriter writer) { AddAttributesToRender(writer); // Make sure we are in a form tag with runat=server. if (Page != null) { Page.VerifyRenderingInServerForm(this); } bool renderWrapper = false; // On wrapper, render ---- attribute and class according to RenderingCompatibility if (!IsEnabled) { if (RenderingCompatibility < VersionUtil.Framework40) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); renderWrapper = true; } else if (!Enabled && !String.IsNullOrEmpty(DisabledCssClass)) { if (String.IsNullOrEmpty(CssClass)) { ControlStyle.CssClass = DisabledCssClass; } else { ControlStyle.CssClass = DisabledCssClass + " " + CssClass; } renderWrapper = true; } } // And Style if (ControlStyleCreated) { Style controlStyle = ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); renderWrapper = true; } } // And ToolTip string toolTip = ToolTip; if (toolTip.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, toolTip); renderWrapper = true; } string onClick = null; // And other attributes if (HasAttributes) { AttributeCollection attribs = Attributes; // remove value from the attribute collection so it's not on the wrapper string val = attribs["value"]; if (val != null) { attribs.Remove("value"); } // remove and save onclick from the attribute collection so we can move it to the input tag onClick = attribs["onclick"]; if (onClick != null) { onClick = Util.EnsureEndWithSemiColon(onClick); attribs.Remove("onclick"); } if (attribs.Count != 0) { attribs.AddAttributes(writer); renderWrapper = true; } if (val != null) { attribs["value"] = val; } } // render begin tag of wrapper SPAN if (renderWrapper) { writer.RenderBeginTag(HtmlTextWriterTag.Span); } string text = Text; string clientID = ClientID; if (text.Length != 0) { if (TextAlign == TextAlign.Left) { // render label to left of checkbox RenderLabel(writer, text, clientID); RenderInputTag(writer, clientID, onClick); } else { // render label to right of checkbox RenderInputTag(writer, clientID, onClick); RenderLabel(writer, text, clientID); } } else { RenderInputTag(writer, clientID, onClick); } // render end tag of wrapper SPAN if (renderWrapper) { writer.RenderEndTag(); } }
/// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RenderVerticalRepeater"]/*' /> /// <devdoc> /// </devdoc> private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { int itemCount = user.RepeatedItemCount; int totalColumns; int totalRows; int filledColumns; if ((repeatColumns == 0) || (repeatColumns == 1)) { // A RepeatColumns of 0 implies a completely vertical repetition in // a single column. This is same as repeatColumns of 1. totalColumns = 1; filledColumns = 1; totalRows = itemCount; } else { totalColumns = repeatColumns; totalRows = (int)((itemCount + repeatColumns - 1) / repeatColumns); if ((totalRows == 0) && (itemCount != 0)) { // if repeatColumns is a huge number like Int32.MaxValue, then the // calculation above essentially reduces down to 0 totalRows = 1; totalColumns = itemCount; } filledColumns = itemCount % totalColumns; if (filledColumns == 0) { filledColumns = totalColumns; } } WebControl outerControl = null; bool tableLayout = false; if (outerTableImplied == false) { switch (repeatLayout) { case RepeatLayout.Table: outerControl = new Table(); tableLayout = true; break; case RepeatLayout.Flow: outerControl = new WebControl(HtmlTextWriterTag.Span); break; } } bool separators = user.HasSeparators; if (outerControl != null) { // use ClientID (and not ID) since we want to render out the fully qualified client id // even though this outer control will not be parented to the control hierarchy outerControl.ID = baseControl.ClientID; outerControl.CopyBaseAttributes(baseControl); outerControl.ApplyStyle(controlStyle); outerControl.RenderBeginTag(writer); } if (user.HasHeader) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TD if (totalColumns != 1) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Header, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Header, -1, this, writer); if (tableLayout) { // render end tag for TR and TD writer.RenderEndTag(); writer.RenderEndTag(); } else if (outerTableImplied == false) { writer.WriteFullBeginTag("br"); } } int itemCounter = 0; for (int currentRow = 0; currentRow < totalRows; currentRow++) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } int itemIndex = currentRow; for (int currentCol = 0; currentCol < totalColumns; currentCol++) { if (itemCounter >= itemCount) { // done rendering all items, so break out of the loop now... // we might end up here, in unfilled columns attempting to re-render items that // have already been rendered on the next column in a prior row. break; } if (currentCol != 0) { itemIndex += totalRows; // if the previous column (currentColumn - 1) was not a filled column, i.e., // it had one less item (the maximum possible), then subtract 1 from the item index. if ((currentCol - 1) >= filledColumns) { itemIndex--; } } if (itemIndex >= itemCount) { continue; } itemCounter++; if (tableLayout) { // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Item, itemIndex); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Item, itemIndex, this, writer); if (tableLayout) { // render end tag for TD writer.RenderEndTag(); } if (separators && (itemIndex != (itemCount - 1))) { if (totalColumns == 1) { if (tableLayout) { writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else { writer.WriteFullBeginTag("br"); } } if (tableLayout) { Style style = user.GetItemStyle(ListItemType.Separator, itemIndex); if (style != null) { style.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } if (itemIndex < itemCount) { user.RenderItem(ListItemType.Separator, itemIndex, this, writer); } if (tableLayout) { writer.RenderEndTag(); } } } if (tableLayout) { writer.RenderEndTag(); } else { if (((currentRow != totalRows - 1) || user.HasFooter) && (outerTableImplied == false)) { writer.WriteFullBeginTag("br"); } } } if (user.HasFooter) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TD if (totalColumns != 1) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Footer, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (tableLayout) { // render end tag for TR and TD writer.RenderEndTag(); writer.RenderEndTag(); } } if (outerControl != null) { outerControl.RenderEndTag(writer); } }
/// <devdoc> /// </devdoc> private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout"); int itemCount = user.RepeatedItemCount; int totalColumns = repeatColumns; int currentColumn = 0; if (totalColumns == 0) { // 0 implies a complete horizontal repetition without any // column count constraints totalColumns = itemCount; } WebControl outerControl = null; bool tableLayout = false; switch (repeatLayout) { case RepeatLayout.Table: outerControl = new Table(); if (Caption.Length != 0) { ((Table)outerControl).Caption = Caption; ((Table)outerControl).CaptionAlign = CaptionAlign; } tableLayout = true; break; case RepeatLayout.Flow: outerControl = new WebControl(HtmlTextWriterTag.Span); break; } bool separators = user.HasSeparators; // use ClientID (and not ID) since we want to render out the fully qualified client id // even though this outer control will not be parented to the control hierarchy outerControl.ID = baseControl.ClientID; outerControl.CopyBaseAttributes(baseControl); outerControl.ApplyStyle(controlStyle); outerControl.RenderBeginTag(writer); if (user.HasHeader) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TD/TH if ((totalColumns != 1) || separators) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } if (useAccessibleHeader) { writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col"); } // add style attributes to render for TD/TH Style style = user.GetItemStyle(ListItemType.Header, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag if (useAccessibleHeader) { writer.RenderBeginTag(HtmlTextWriterTag.Th); } else { writer.RenderBeginTag(HtmlTextWriterTag.Td); } } user.RenderItem(ListItemType.Header, -1, this, writer); if (tableLayout) { // render end tags TD/TH and TR writer.RenderEndTag(); writer.RenderEndTag(); } else { if (totalColumns < itemCount) { // we have multiple rows, so have a break between the header and first row. if (EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } } for (int i = 0; i < itemCount; i++) { if (tableLayout && (currentColumn == 0)) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } if (tableLayout) { // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Item, i); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Item, i, this, writer); if (tableLayout) { // render end tag for TD writer.RenderEndTag(); } if (separators && (i != (itemCount - 1))) { if (tableLayout) { Style style = user.GetItemStyle(ListItemType.Separator, i); if (style != null) { style.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Separator, i, this, writer); if (tableLayout) { writer.RenderEndTag(); } } currentColumn++; // on the last line, fill in the rest of the empty spots with <td/>s. // If there were separators, we need twice as many plus one to accomodate for // the last item not having a separator after it. if (tableLayout && i == itemCount - 1) { int unfilledColumns = totalColumns - currentColumn; if (separators == true) { int unfilledColumnsWithSeparators = (unfilledColumns * 2) + 1; if (unfilledColumnsWithSeparators > unfilledColumns) { unfilledColumns = unfilledColumnsWithSeparators; } } for (int k = 0; k < unfilledColumns; k++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } if ((currentColumn == totalColumns) || (i == itemCount - 1)) { if (tableLayout) { // End tag for TR writer.RenderEndTag(); } else { // write out the <br> after rows when there are multiple rows if (totalColumns < itemCount) { if (EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } currentColumn = 0; } } if (user.HasFooter) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); if ((totalColumns != 1) || separators) { // add attributes to render for TD int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Footer, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (tableLayout) { // render end tag for TR and TD writer.RenderEndTag(); writer.RenderEndTag(); } } outerControl.RenderEndTag(writer); }
protected override void RenderMenuItem(HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; string clientID = oc.ClientID; bool displayChildren = owner.DisplayChildren(item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels); bool isDynamicItem = IsDynamicItem(owner, item); bool isVertical = oc.IsVertical || isDynamicItem; Unit itemSpacing = owner.GetItemSpacing(item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) { RenderMenuItemSpacing(writer, itemSpacing, isVertical); } if (!String.IsNullOrEmpty(item.ToolTip)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip); } if (isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute("onmouseover", "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')"); writer.AddAttribute("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem) { RenderSeparatorImage(owner, writer, oc.DynamicTopSeparatorImageUrl, false); } else { RenderSeparatorImage(owner, writer, oc.StaticTopSeparatorImageUrl, false); } // Menu item box MenuItemStyle style = new MenuItemStyle(); if (oc.Header != null) { // styles are registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass(style, oc.StaticMenuItemStyle.CssClass); AddCssClass(style, oc.StaticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass(style, oc.DynamicMenuItemStyle.CssClass); AddCssClass(style, oc.DynamicMenuItemStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass(style, oc.StaticSelectedStyle.CssClass); AddCssClass(style, oc.StaticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass(style, oc.DynamicSelectedStyle.CssClass); AddCssClass(style, oc.DynamicSelectedStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass(style, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass(style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { style.CopyFrom(oc.StaticMenuItemStyle); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { style.CopyFrom(oc.DynamicMenuItemStyle); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { style.CopyFrom(oc.LevelMenuItemStyles [item.Depth]); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { style.CopyFrom(oc.StaticSelectedStyle); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { style.CopyFrom(oc.DynamicSelectedStyle); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { style.CopyFrom(oc.LevelSelectedStyles [item.Depth]); } } } style.AddAttributesToRender(writer); writer.AddAttribute("id", GetItemClientId(clientID, item, "i")); writer.AddAttribute("cellpadding", "0", false); writer.AddAttribute("cellspacing", "0", false); writer.AddAttribute("border", "0", false); writer.AddAttribute("width", "100%", false); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Menu item text if (isVertical) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } if (!owner.ItemWrap) { writer.AddStyleAttribute("white-space", "nowrap"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderItemHref(owner, writer, item); Style linkStyle = new Style(); if (oc.Header != null) { // styles are registered AddCssClass(linkStyle, oc.ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass(linkStyle, oc.StaticMenuItemStyle.CssClass); AddCssClass(linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass(linkStyle, oc.DynamicMenuItemStyle.CssClass); AddCssClass(linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass(linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass(linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass(linkStyle, oc.StaticSelectedStyle.CssClass); AddCssClass(linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass(linkStyle, oc.DynamicSelectedStyle.CssClass); AddCssClass(linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass(linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass(linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom(oc.ControlLinkStyle); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { linkStyle.CopyFrom(oc.StaticMenuItemLinkStyle); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { linkStyle.CopyFrom(oc.DynamicMenuItemLinkStyle); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { linkStyle.CopyFrom(oc.LevelMenuItemLinkStyles [item.Depth]); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { linkStyle.CopyFrom(oc.StaticSelectedLinkStyle); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { linkStyle.CopyFrom(oc.DynamicSelectedLinkStyle); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { linkStyle.CopyFrom(oc.LevelSelectedLinkStyles [item.Depth]); } } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender(writer); writer.AddAttribute("id", GetItemClientId(clientID, item, "l")); if (item.Depth > 0 && !isDynamicItem) { double value; #if NET_4_0 Unit unit = oc.StaticSubMenuIndent; if (unit == Unit.Empty) { value = 16; } else { value = unit.Value; } #else value = oc.StaticSubMenuIndent.Value; #endif Unit indent = new Unit(value * item.Depth, oc.StaticSubMenuIndent.Type); writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, indent.ToString()); } writer.RenderBeginTag(HtmlTextWriterTag.A); owner.RenderItemContent(writer, item, isDynamicItem); writer.RenderEndTag(); // A writer.RenderEndTag(); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage(owner, item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute("src", owner.ResolveClientUrl(popOutImage)); writer.AddAttribute("border", "0"); string toolTip = String.Format(isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute(HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // IMG writer.RenderEndTag(); // TD } } writer.RenderEndTag(); // TR writer.RenderEndTag(); // TABLE writer.RenderEndTag(); // TD if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute("width", "3px"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) { separatorImg = oc.DynamicBottomSeparatorImageUrl; } else { separatorImg = oc.StaticBottomSeparatorImageUrl; } } if (separatorImg.Length > 0) { if (!isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Td); } RenderSeparatorImage(owner, writer, separatorImg, false); if (!isVertical) { writer.RenderEndTag(); // TD } } if (isVertical) { writer.RenderEndTag(); // TR } if (itemSpacing != Unit.Empty) { RenderMenuItemSpacing(writer, itemSpacing, isVertical); } // Submenu if (displayChildren && !dynamicChildren) { if (isVertical) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute("width", "100%"); owner.RenderMenu(writer, item.ChildItems, vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == oc.StaticDisplayLevels) { owner.RenderDynamicMenu(writer, item.ChildItems); } writer.RenderEndTag(); // TD if (isVertical) { writer.RenderEndTag(); // TR } } }
/// <devdoc> /// </devdoc> private void RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { int itemCount = user.RepeatedItemCount; int totalColumns; int totalRows; int filledColumns; // List Layout Constraint --> Columns = 0 or 1 if ((repeatColumns == 0) || (repeatColumns == 1)) { // A RepeatColumns of 0 implies a completely vertical repetition in // a single column. This is same as repeatColumns of 1. totalColumns = 1; filledColumns = 1; totalRows = itemCount; } else { totalColumns = repeatColumns; totalRows = (int)((itemCount + repeatColumns - 1) / repeatColumns); if ((totalRows == 0) && (itemCount != 0)) { // if repeatColumns is a huge number like Int32.MaxValue, then the // calculation above essentially reduces down to 0 totalRows = 1; } filledColumns = itemCount % totalColumns; if (filledColumns == 0) { filledColumns = totalColumns; } } WebControl outerControl = null; bool tableLayout = false; // List Layout Constraint --> OuterTableImplied = false // List Layout Constraint --> tableLayout = false if (!outerTableImplied) { switch (repeatLayout) { case RepeatLayout.Table: outerControl = new Table(); if (Caption.Length != 0) { ((Table)outerControl).Caption = Caption; ((Table)outerControl).CaptionAlign = CaptionAlign; } tableLayout = true; break; case RepeatLayout.Flow: outerControl = new WebControl(HtmlTextWriterTag.Span); break; case RepeatLayout.UnorderedList: outerControl = new WebControl(HtmlTextWriterTag.Ul); break; case RepeatLayout.OrderedList: outerControl = new WebControl(HtmlTextWriterTag.Ol); break; } } bool separators = user.HasSeparators; // List Layout Constraint --> separators = false if (outerControl != null) { // use ClientID (and not ID) since we want to render out the fully qualified client id // even though this outer control will not be parented to the control hierarchy outerControl.ID = baseControl.ClientID; outerControl.CopyBaseAttributes(baseControl); outerControl.ApplyStyle(controlStyle); outerControl.RenderBeginTag(writer); } // List Layout Constraint --> HasHeader = false if (user.HasHeader) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TH if (totalColumns != 1) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } if (useAccessibleHeader) { writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col"); } // add style attributes to render for TD/TH Style style = user.GetItemStyle(ListItemType.Header, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD/TH if (useAccessibleHeader) { writer.RenderBeginTag(HtmlTextWriterTag.Th); } else { writer.RenderBeginTag(HtmlTextWriterTag.Td); } } user.RenderItem(ListItemType.Header, -1, this, writer); if (tableLayout) { // render end tags TD/TH and TR writer.RenderEndTag(); writer.RenderEndTag(); } else if (!outerTableImplied) { if (EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } int itemCounter = 0; for (int currentRow = 0; currentRow < totalRows; currentRow++) { // List Layout Constraint --> tableLayout = false if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); } int itemIndex = currentRow; for (int currentCol = 0; currentCol < totalColumns; currentCol++) { if (itemCounter >= itemCount) { // done rendering all items, so break out of the loop now... // we might end up here, in unfilled columns attempting to re-render items that // have already been rendered on the next column in a prior row. break; } if (currentCol != 0) { itemIndex += totalRows; // if the previous column (currentColumn - 1) was not a filled column, i.e., // it had one less item (the maximum possible), then subtract 1 from the item index. if ((currentCol - 1) >= filledColumns) { itemIndex--; } } if (itemIndex >= itemCount) { continue; } itemCounter++; // List Layout Constraint --> tableLayout = false if (tableLayout) { // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Item, itemIndex); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } if (IsListLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Li); } user.RenderItem(ListItemType.Item, itemIndex, this, writer); if (IsListLayout) { writer.RenderEndTag(); writer.WriteLine(); } // List Layout Constraint --> tableLayout = false if (tableLayout) { // render end tag for TD writer.RenderEndTag(); } // List Layout Constraint --> separators = false if (separators) { if (itemIndex != (itemCount - 1)) { if (totalColumns == 1) { if (tableLayout) { writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Tr); } else { if (!outerTableImplied) { if (EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } } if (tableLayout) { Style style = user.GetItemStyle(ListItemType.Separator, itemIndex); if (style != null) { style.AddAttributesToRender(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); } if (itemIndex < itemCount) { user.RenderItem(ListItemType.Separator, itemIndex, this, writer); } if (tableLayout) { writer.RenderEndTag(); } } else { // if we're on the last filled line and separators are specified, add another <td/> // to accomodate for the lack of a separator on the last item. If there's only one // column, though, separators will get their own row anyways. if (tableLayout && totalColumns > 1) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } } } // on the last line, fill in the remaining empty slots with <td/>s. We need twice as many // if there were separators. // List Layout Constraint --> tableLayout = false if (tableLayout) { if (currentRow == totalRows - 1) { int unfilledColumns = totalColumns - filledColumns; if (separators) { int unfilledColumnsWithSeparators = unfilledColumns * 2; if (unfilledColumnsWithSeparators >= unfilledColumns) { unfilledColumns = unfilledColumnsWithSeparators; } } if (unfilledColumns != 0) { for (int i = 0; i < unfilledColumns; i++) { writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderEndTag(); } } } writer.RenderEndTag(); } else { if (((currentRow != totalRows - 1) || user.HasFooter) && (!outerTableImplied) && (!IsListLayout)) { if (EnableLegacyRendering) { writer.WriteObsoleteBreak(); } else { writer.WriteBreak(); } } } } // List Layout Constraint --> HasFooter = false if (user.HasFooter) { if (tableLayout) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // add attributes to render for TD if (totalColumns != 1) { int columnSpan = totalColumns; if (separators) { columnSpan += totalColumns; } writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo)); } // add style attributes to render for TD Style style = user.GetItemStyle(ListItemType.Footer, -1); if (style != null) { style.AddAttributesToRender(writer); } // render begin tag for TD writer.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Footer, -1, this, writer); if (tableLayout) { // render end tag for TR and TD writer.RenderEndTag(); writer.RenderEndTag(); } } if (outerControl != null) { outerControl.RenderEndTag(writer); } }
void RenderHoriz(HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) { int itms = user.RepeatedItemCount; // total number of rows/columns in our table int cols = RepeatColumns == 0 ? itms : RepeatColumns; // this gets ceil (itms / cols) int rows = cols == 0 ? 0 : (itms + cols - 1) / cols; bool sep = user.HasSeparators; //bool oti = OuterTableImplied; int hdr_span = cols * (sep ? 2 : 1); bool table = RepeatLayout == RepeatLayout.Table; bool show_empty_trailing_items = true; bool show_empty_trailing_sep = true; RenderBeginTag(w, controlStyle, baseControl); if (Caption.Length > 0) { if (CaptionAlign != TableCaptionAlign.NotSet) { w.AddAttribute(HtmlTextWriterAttribute.Align, CaptionAlign.ToString()); } w.RenderBeginTag(HtmlTextWriterTag.Caption); w.Write(Caption); w.RenderEndTag(); } // Render the header if (user.HasHeader) { if (table) { w.RenderBeginTag(HtmlTextWriterTag.Tr); // Make sure the header takes up the full width. We have two // columns per item if we are using separators, otherwise // one per item. if (hdr_span != 1) { w.AddAttribute(HtmlTextWriterAttribute.Colspan, hdr_span.ToString(), false); } if (UseAccessibleHeader) { w.AddAttribute("scope", "col", false); } Style s = user.GetItemStyle(ListItemType.Header, -1); if (s != null) { s.AddAttributesToRender(w); } if (UseAccessibleHeader) { w.RenderBeginTag(HtmlTextWriterTag.Th); } else { w.RenderBeginTag(HtmlTextWriterTag.Td); } user.RenderItem(ListItemType.Header, -1, this, w); w.RenderEndTag(); // td w.RenderEndTag(); // tr } else { user.RenderItem(ListItemType.Header, -1, this, w); if (!table && RepeatColumns != 0 && itms != 0) { RenderBr(w); } } } for (int r = 0; r < rows; r++) { if (table) { w.RenderBeginTag(HtmlTextWriterTag.Tr); } for (int c = 0; c < cols; c++) { // Find the item number we are in according to the repeat // direction. int item = r * cols + c; // This item is blank because there there not enough items // to make a full row. if (!show_empty_trailing_items && item >= itms) { continue; } if (table) { Style s = null; if (item < itms) { s = user.GetItemStyle(ListItemType.Item, item); } if (s != null) { s.AddAttributesToRender(w); } w.RenderBeginTag(HtmlTextWriterTag.Td); } if (item < itms) { user.RenderItem(ListItemType.Item, item, this, w); } if (table) { w.RenderEndTag(); // td } if (sep) { if (table) { if (item < itms - 1) { Style s = user.GetItemStyle(ListItemType.Separator, item); if (s != null) { s.AddAttributesToRender(w); } } if (item < itms - 1 || show_empty_trailing_sep) { w.RenderBeginTag(HtmlTextWriterTag.Td); } } if (item < itms - 1) { user.RenderItem(ListItemType.Separator, item, this, w); } if (table && (item < itms - 1 || show_empty_trailing_sep)) { w.RenderEndTag(); // td } } } if (table) { // if (!oti) w.RenderEndTag(); // tr } else if (!(r == rows - 1 && RepeatColumns == 0)) { RenderBr(w); } } // Render the footer if (user.HasFooter) { if (table) { w.RenderBeginTag(HtmlTextWriterTag.Tr); if (hdr_span != 1) { w.AddAttribute(HtmlTextWriterAttribute.Colspan, hdr_span.ToString(), false); } Style s = user.GetItemStyle(ListItemType.Footer, -1); if (s != null) { s.AddAttributesToRender(w); } w.RenderBeginTag(HtmlTextWriterTag.Td); user.RenderItem(ListItemType.Footer, -1, this, w); w.RenderEndTag(); // td w.RenderEndTag(); // tr } else { user.RenderItem(ListItemType.Footer, -1, this, w); } } if (true) { w.RenderEndTag(); // table/span } }
protected override void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc) { Menu owner = Owner; string clientID = oc.ClientID; bool displayChildren = owner.DisplayChildren (item); bool dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels); bool isDynamicItem = IsDynamicItem (owner, item); bool isVertical = oc.IsVertical || isDynamicItem; Unit itemSpacing = owner.GetItemSpacing (item, isDynamicItem); if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst)) RenderMenuItemSpacing (writer, itemSpacing, isVertical); if(!String.IsNullOrEmpty(item.ToolTip)) writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip); if (isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null"; if (dynamicChildren) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } else if (isDynamicItem) { writer.AddAttribute ("onmouseover", "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")"); } else { writer.AddAttribute ("onmouseover", "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')"); writer.AddAttribute ("onmouseout", "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')"); } writer.RenderBeginTag (HtmlTextWriterTag.Td); // Top separator image if (isDynamicItem) RenderSeparatorImage (owner, writer, oc.DynamicTopSeparatorImageUrl, false); else RenderSeparatorImage (owner, writer, oc.StaticTopSeparatorImageUrl, false); // Menu item box MenuItemStyle style = new MenuItemStyle (); if (oc.Header != null) { // styles are registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass (style, oc.StaticMenuItemStyle.CssClass); AddCssClass (style, oc.StaticMenuItemStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass (style, oc.DynamicMenuItemStyle.CssClass); AddCssClass (style, oc.DynamicMenuItemStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass (style, oc.StaticSelectedStyle.CssClass); AddCssClass (style, oc.StaticSelectedStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass (style, oc.DynamicSelectedStyle.CssClass); AddCssClass (style, oc.DynamicSelectedStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass (style, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass (style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered if (!isDynamicItem && oc.StaticMenuItemStyle != null) style.CopyFrom (oc.StaticMenuItemStyle); if (isDynamicItem && oc.DynamicMenuItemStyle != null) style.CopyFrom (oc.DynamicMenuItemStyle); if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) style.CopyFrom (oc.LevelMenuItemStyles [item.Depth]); if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) style.CopyFrom (oc.StaticSelectedStyle); if (isDynamicItem && oc.DynamicSelectedStyle != null) style.CopyFrom (oc.DynamicSelectedStyle); if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) style.CopyFrom (oc.LevelSelectedStyles [item.Depth]); } } style.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (clientID, item, "i")); writer.AddAttribute ("cellpadding", "0", false); writer.AddAttribute ("cellspacing", "0", false); writer.AddAttribute ("border", "0", false); writer.AddAttribute ("width", "100%", false); writer.RenderBeginTag (HtmlTextWriterTag.Table); writer.RenderBeginTag (HtmlTextWriterTag.Tr); // Menu item text if (isVertical) writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%"); if (!owner.ItemWrap) writer.AddStyleAttribute ("white-space", "nowrap"); writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderItemHref (owner, writer, item); Style linkStyle = new Style (); if (oc.Header != null) { // styles are registered AddCssClass (linkStyle, oc.ControlLinkStyle.RegisteredCssClass); if (!isDynamicItem && oc.StaticMenuItemStyle != null) { AddCssClass (linkStyle, oc.StaticMenuItemStyle.CssClass); AddCssClass (linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicMenuItemStyle != null) { AddCssClass (linkStyle, oc.DynamicMenuItemStyle.CssClass); AddCssClass (linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass); } if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) { AddCssClass (linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass); AddCssClass (linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass); } if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) { AddCssClass (linkStyle, oc.StaticSelectedStyle.CssClass); AddCssClass (linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass); } if (isDynamicItem && oc.DynamicSelectedStyle != null) { AddCssClass (linkStyle, oc.DynamicSelectedStyle.CssClass); AddCssClass (linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass); } if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) { AddCssClass (linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass); AddCssClass (linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass); } } } else { // styles are not registered linkStyle.CopyFrom (oc.ControlLinkStyle); if (!isDynamicItem && oc.StaticMenuItemStyle != null) linkStyle.CopyFrom (oc.StaticMenuItemLinkStyle); if (isDynamicItem && oc.DynamicMenuItemStyle != null) linkStyle.CopyFrom (oc.DynamicMenuItemLinkStyle); if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) linkStyle.CopyFrom (oc.LevelMenuItemLinkStyles [item.Depth]); if (item == oc.SelectedItem) { if (!isDynamicItem && oc.StaticSelectedStyle != null) linkStyle.CopyFrom (oc.StaticSelectedLinkStyle); if (isDynamicItem && oc.DynamicSelectedStyle != null) linkStyle.CopyFrom (oc.DynamicSelectedLinkStyle); if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) linkStyle.CopyFrom (oc.LevelSelectedLinkStyles [item.Depth]); } linkStyle.AlwaysRenderTextDecoration = true; } linkStyle.AddAttributesToRender (writer); writer.AddAttribute ("id", GetItemClientId (clientID, item, "l")); if (item.Depth > 0 && !isDynamicItem) { double value; Unit unit = oc.StaticSubMenuIndent; if (unit == Unit.Empty) value = 16; else value = unit.Value; Unit indent = new Unit (value * item.Depth, oc.StaticSubMenuIndent.Type); writer.AddStyleAttribute (HtmlTextWriterStyle.MarginLeft, indent.ToString ()); } writer.RenderBeginTag (HtmlTextWriterTag.A); owner.RenderItemContent (writer, item, isDynamicItem); writer.RenderEndTag (); // A writer.RenderEndTag (); // TD // Popup image if (dynamicChildren) { string popOutImage = GetPopOutImage (owner, item, isDynamicItem); if (popOutImage != null) { writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("src", owner.ResolveClientUrl (popOutImage)); writer.AddAttribute ("border", "0"); string toolTip = String.Format (isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text); writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip); writer.RenderBeginTag (HtmlTextWriterTag.Img); writer.RenderEndTag (); // IMG writer.RenderEndTag (); // TD } } writer.RenderEndTag (); // TR writer.RenderEndTag (); // TABLE writer.RenderEndTag (); // TD if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) { writer.AddStyleAttribute ("width", "3px"); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.RenderEndTag (); } // Bottom separator image string separatorImg = item.SeparatorImageUrl; if (separatorImg.Length == 0) { if (isDynamicItem) separatorImg = oc.DynamicBottomSeparatorImageUrl; else separatorImg = oc.StaticBottomSeparatorImageUrl; } if (separatorImg.Length > 0) { if (!isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Td); RenderSeparatorImage (owner, writer, separatorImg, false); if (!isVertical) writer.RenderEndTag (); // TD } if (isVertical) writer.RenderEndTag (); // TR if (itemSpacing != Unit.Empty) RenderMenuItemSpacing (writer, itemSpacing, isVertical); // Submenu if (displayChildren && !dynamicChildren) { if (isVertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr); writer.RenderBeginTag (HtmlTextWriterTag.Td); writer.AddAttribute ("width", "100%"); owner.RenderMenu (writer, item.ChildItems, vertical, false, item.Depth + 1, notLast); if (item.Depth + 2 == oc.StaticDisplayLevels) owner.RenderDynamicMenu (writer, item.ChildItems); writer.RenderEndTag (); // TD if (isVertical) writer.RenderEndTag (); // TR } }
protected override void RenderHeader(HtmlTextWriter writer) { // // Render title bar writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); TitleStyle headerStyle = HeaderStyle; if (!headerStyle.IsEmpty) { // Apply font and forecolor from HeaderStyle to inner table Style style = new Style(); if (!headerStyle.ForeColor.IsEmpty) { style.ForeColor = headerStyle.ForeColor; } style.Font.CopyFrom(headerStyle.Font); if (!headerStyle.Font.Size.IsEmpty) { // If the font size is specified on the HeaderStyle, force the font size to 100%, // so it inherits the font size from its parent in IE compatibility mode. I would // think that "1em" would work here as well, but "1em" doesn't work when you change // the font size in the browser. style.Font.Size = new FontUnit(new Unit(100, UnitType.Percentage)); } if (!style.IsEmpty) { style.AddAttributesToRender(writer, this); } } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Copied from Panel.cs // HorizontalAlign hAlign = headerStyle.HorizontalAlign; if (hAlign != HorizontalAlign.NotSet) { TypeConverter hac = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddAttribute(HtmlTextWriterAttribute.Align, hac.ConvertToString(hAlign)); } writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(DisplayTitle); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr writer.RenderEndTag(); // Table }
protected override void RenderHeader(HtmlTextWriter writer) { // Render title bar writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); TitleStyle headerStyle = HeaderStyle; if (!headerStyle.IsEmpty) { // Apply font and forecolor from HeaderStyle to inner table Style style = new Style(); if (!headerStyle.ForeColor.IsEmpty) { style.ForeColor = headerStyle.ForeColor; } style.Font.CopyFrom(headerStyle.Font); if (!headerStyle.Font.Size.IsEmpty) { // If the font size is specified on the HeaderStyle, force the font size to 100%, // so it inherits the font size from its parent in IE compatibility mode. I would // think that "1em" would work here as well, but "1em" doesn't work when you change // the font size in the browser. style.Font.Size = new FontUnit(new Unit(100, UnitType.Percentage)); } if (!style.IsEmpty) { style.AddAttributesToRender(writer, this); } } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Copied from Panel.cs // HorizontalAlign hAlign = headerStyle.HorizontalAlign; if (hAlign != HorizontalAlign.NotSet) { TypeConverter hac = TypeDescriptor.GetConverter(typeof(HorizontalAlign)); writer.AddAttribute(HtmlTextWriterAttribute.Align, hac.ConvertToString(hAlign)); } writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(HeaderText); writer.RenderEndTag(); // Td WebPartVerb headerCloseVerb = HeaderCloseVerb; if (headerCloseVerb.Visible) { writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); ZoneLinkButton closeButton = new ZoneLinkButton(this, headerCloseVerb.EventArgument); closeButton.Text = headerCloseVerb.Text; closeButton.ImageUrl = headerCloseVerb.ImageUrl; closeButton.ToolTip = headerCloseVerb.Description; closeButton.Enabled = headerCloseVerb.Enabled; closeButton.Page = Page; closeButton.ApplyStyle(HeaderVerbStyle); closeButton.RenderControl(writer); writer.RenderEndTag(); // Td } writer.RenderEndTag(); // Tr writer.RenderEndTag(); // Table }
private void RenderListBox(string listType, object dataSource, Style style, HtmlTextWriter writer) { if (dataSource != null) { NameValueCollection list = GetList(listType, dataSource); if (list != null) { if (style != null) { style.AddAttributesToRender(writer); } //Render ListBox writer.AddAttribute(HtmlTextWriterAttribute.Multiple, "multiple"); writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "_" + listType); writer.RenderBeginTag(HtmlTextWriterTag.Select); for (int i = 0; i <= list.Count - 1; i++) { //Render option tags for each item writer.AddAttribute(HtmlTextWriterAttribute.Value, list.Get(i)); writer.RenderBeginTag(HtmlTextWriterTag.Option); writer.Write(list.GetKey(i)); writer.RenderEndTag(); } //Render ListBox end writer.RenderEndTag(); } } }
/// <include file='doc\CheckBox.uex' path='docs/doc[@for="CheckBox.Render"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Displays the <see cref='System.Web.UI.WebControls.CheckBox'/> on the client.</para> /// </devdoc> protected override void Render(HtmlTextWriter writer) { // Render the wrapper span // Make sure we are in a form tag with runat=server. if (Page != null) { Page.VerifyRenderingInServerForm(this); } bool renderWrapper = false; // On wrapper, render the style, if (ControlStyleCreated) { Style controlStyle = ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); renderWrapper = true; } } // And Enabled if (!Enabled) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); renderWrapper = true; } // And ToolTip string toolTip = ToolTip; if (toolTip.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, toolTip); renderWrapper = true; } string onClick = null; // And other attributes if (HasAttributes) { System.Web.UI.AttributeCollection attribs = Attributes; // remove value from the attribute collection so it's not on the wrapper string val = attribs["value"]; if (val != null) { attribs.Remove("value"); } // remove and save onclick from the attribute collection so we can move it to the input tag onClick = attribs["onclick"]; if (onClick != null) { attribs.Remove("onclick"); } if (attribs.Count != 0) { attribs.AddAttributes(writer); renderWrapper = true; } if (val != null) { attribs["value"] = val; } } // render begin tag of wrapper SPAN if (renderWrapper) { writer.RenderBeginTag(HtmlTextWriterTag.Span); } string text = Text; string clientID = ClientID; if (text.Length != 0) { if (TextAlign == TextAlign.Left) { // render label to left of checkbox RenderLabel(writer, text, clientID); RenderInputTag(writer, clientID, onClick); } else { // render label to right of checkbox RenderInputTag(writer, clientID, onClick); RenderLabel(writer, text, clientID); } } else { RenderInputTag(writer, clientID, onClick); } // render end tag of wrapper SPAN if (renderWrapper) { writer.RenderEndTag(); } }