protected override void Render(HtmlTextWriter InWriter) { InWriter.AddStyleAttribute("font-family", "Verdana,Arial"); InWriter.RenderBeginTag("table"); InWriter.RenderBeginTag("tr"); InWriter.AddStyleAttribute("font-weight", "bold"); InWriter.AddStyleAttribute("font-size", "larger"); InWriter.AddStyleAttribute("color", ColorTranslator.ToHtml(mTitleColor)); InWriter.RenderBeginTag("td"); InWriter.Write("article title text"); InWriter.RenderEndTag( ); InWriter.RenderEndTag( ); InWriter.RenderBeginTag("tr"); InWriter.RenderBeginTag("td"); InWriter.Write("article body text<br>line 2 of the article."); InWriter.RenderEndTag( ); InWriter.RenderEndTag( ); InWriter.RenderBeginTag("tr"); mUrlStyle.AddAttributesToRender(InWriter); InWriter.RenderBeginTag("td"); InWriter.Write("url to the full article. " + mShow.Title); InWriter.RenderEndTag( ); InWriter.RenderEndTag( ); InWriter.RenderEndTag( ); }
/// <summary> Renders the opening tag for the command. </summary> /// <param name="writer"> The <see cref="HtmlTextWriter"/> object to use. Must not be <see langword="null"/>. </param> /// <param name="renderingFeatures"> The rendering features to use. </param> /// <param name="postBackEvent"> /// The string executed upon the click on a command of types /// <see cref="CommandType.Event"/> or <see cref="CommandType.WxeFunction"/>. /// This string is usually the call to the <c>__doPostBack</c> script function used by ASP.net /// to force a post back. /// </param> /// <param name="parameters"> /// The strings inserted into the href attribute using <c>string.Format</c>. /// </param> /// <param name="onClick"> /// The string always rendered in the <c>onClick</c> tag of the anchor element. /// </param> /// <param name="securableObject"> /// The <see cref="ISecurableObject"/> for which security is evaluated. Use <see landword="null"/> if security is stateless or not evaluated. /// </param> /// <param name="additionalUrlParameters"> /// The <see cref="NameValueCollection"/> containing additional url parameters. /// Must not be <see langword="null"/>. /// </param> /// <param name="includeNavigationUrlParameters"> /// <see langword="true"/> to include URL parameters provided by <see cref="ISmartNavigablePage"/>. /// </param> /// <param name="style"> The style applied to the opening tag. </param> public virtual void RenderBegin( HtmlTextWriter writer, IRenderingFeatures renderingFeatures, string postBackEvent, string[] parameters, string onClick, ISecurableObject securableObject, NameValueCollection additionalUrlParameters, bool includeNavigationUrlParameters, Style style) { ArgumentUtility.CheckNotNull("writer", writer); ArgumentUtility.CheckNotNull("style", style); var commandInfo = GetCommandInfo(postBackEvent, parameters, onClick, securableObject, additionalUrlParameters, includeNavigationUrlParameters); if (commandInfo != null) { commandInfo.AddAttributesToRender(writer, renderingFeatures); } if (OwnerControl != null && !string.IsNullOrEmpty(OwnerControl.ClientID) && !string.IsNullOrEmpty(ItemID)) { var clientID = OwnerControl.ClientID + "_" + ItemID; writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID); } style.AddAttributesToRender(writer); writer.RenderBeginTag(HtmlTextWriterTag.A); }
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(); }
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(); } } }
private void RenderPartContentsInternal(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } Style style2 = this.Zone.PartStyle; var editorName = editorPart.GetType().Name; if (!style2.IsEmpty) { style2.AddAttributesToRender(writer, this.Zone); } AddAttributes(writer, editorPart); writer.RenderBeginTag(HtmlTextWriterTag.Div); if (!editorName.Equals("PropertyEditorPart")) { PropertyFieldPanel.RenderBeginTagInternal(writer, editorPart.Title, editorPart.ID); PropertyFieldPanel.RenderContentsStart(writer); } this.RenderPartContents(writer, editorPart); if (!editorName.Equals("PropertyEditorPart")) { PropertyFieldPanel.RenderContentsEnd(writer); PropertyFieldPanel.RenderEndTagInternal(writer); } writer.RenderEndTag(); this.EditorZone.EditorPartsAdded = true; }
public virtual void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } PartChromeType effectiveChromeType = this.Zone.GetEffectiveChromeType(editorPart); Style style = this.CreateEditorPartChromeStyle(editorPart, effectiveChromeType); if (!style.IsEmpty) { style.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); switch (effectiveChromeType) { case PartChromeType.TitleAndBorder: case PartChromeType.TitleOnly: this.RenderTitle(writer, editorPart); break; } if (editorPart.ChromeState != PartChromeState.Minimized) { Style partStyle = this.Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Div); this.RenderPartContents(writer, editorPart); writer.RenderEndTag(); } writer.RenderEndTag(); }
private void RenderPlaceHolder(SingleViewRenderingContext renderingContext, Style style, PlaceHolder placeHolder, string defaultCssClass) { ScriptUtility.Instance.RegisterElementForBorderSpans(renderingContext.Control, "#" + placeHolder.ClientID); string cssClass = defaultCssClass; if (!string.IsNullOrEmpty(style.CssClass)) { cssClass = style.CssClass; } if (placeHolder.Controls.Count == 0) { cssClass += " " + CssClassEmpty; } string backupCssClass = style.CssClass; style.CssClass = cssClass; style.AddAttributesToRender(renderingContext.Writer); style.CssClass = backupCssClass; renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, placeHolder.ClientID); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassContent); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); placeHolder.RenderControl(renderingContext.Writer); renderingContext.Writer.RenderEndTag(); renderingContext.Writer.RenderEndTag(); }
private void RenderLabel(HtmlTextWriter writer, string clientID, WebPart associatedWebPart) { this._menuUser.OnBeginRender(writer); if (associatedWebPart != null) { writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID); Style labelStyle = this._menuUser.LabelStyle; if (labelStyle != null) { labelStyle.AddAttributesToRender(writer, this._menuUser as WebControl); } } writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "hand"); writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "inline-block"); writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "1px"); writer.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); writer.RenderBeginTag(HtmlTextWriterTag.Span); string labelImageUrl = this._menuUser.LabelImageUrl; string labelText = this._menuUser.LabelText; if (!string.IsNullOrEmpty(labelImageUrl)) { writer.AddAttribute(HtmlTextWriterAttribute.Src, labelImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, !string.IsNullOrEmpty(labelText) ? labelText : System.Web.SR.GetString("WebPartMenu_DefaultDropDownAlternateText"), true); writer.AddStyleAttribute("vertical-align", "middle"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.Write(" "); } if (!string.IsNullOrEmpty(labelText)) { writer.Write(labelText); writer.Write(" "); } writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "Popup"); string popupImageUrl = this._menuUser.PopupImageUrl; if (!string.IsNullOrEmpty(popupImageUrl)) { writer.AddAttribute(HtmlTextWriterAttribute.Src, popupImageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, !string.IsNullOrEmpty(labelText) ? labelText : System.Web.SR.GetString("WebPartMenu_DefaultDropDownAlternateText"), true); writer.AddStyleAttribute("vertical-align", "middle"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "Marlett"); writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "8pt"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write("u"); writer.RenderEndTag(); } writer.RenderEndTag(); this._menuUser.OnEndRender(writer); }
public virtual void RenderEditorPart(HtmlTextWriter writer, EditorPart editorPart) { if (editorPart == null) { throw new ArgumentNullException("editorPart"); } PartChromeType chromeType = Zone.GetEffectiveChromeType(editorPart); Style partChromeStyle = CreateEditorPartChromeStyle(editorPart, chromeType); // Apply ChromeStyle to the Fieldset if (!partChromeStyle.IsEmpty) { partChromeStyle.AddAttributesToRender(writer, Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Fieldset); // Use ChromeType to determine whether to render the legend if (chromeType == PartChromeType.TitleAndBorder || chromeType == PartChromeType.TitleOnly) { RenderTitle(writer, editorPart); } if (editorPart.ChromeState != PartChromeState.Minimized) { // Apply PartStyle to a <div> around the part rendering Style partStyle = Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, Zone); } // We want to have 5 pixels of spacing aroung the EditorPart contents. There are // 3 ways to accomplish this: // 1. <fieldset style="padding:5px"> - This is bad because it adds 5px of space above // the legend. It also makes the fieldset too wide. // 2. <fieldset><div style="padding:5px"> - This is bad because the PartStyle-BackColor // will now span the whole width of the legend. For consistency with WebPartChrome, // we want the PartChromeStyle-BackColor to show in the 5px of space around the contents. // 3. <fieldset><div style="margin:5px"> - This is the best option. // // For now, I don't think we should render a margin here. People writing custom // EditorParts can add a margin to their contents if they want it. This is not the // same as the WebPartChrome case, since for WebParts we allow people to use ServerControls, // that will likely not have a margin. (VSWhidbey 324397) // writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "5px"); writer.RenderBeginTag(HtmlTextWriterTag.Div); RenderPartContents(writer, editorPart); writer.RenderEndTag(); // Div } writer.RenderEndTag(); // Fieldset }
public virtual void RenderCatalogPart(HtmlTextWriter writer, CatalogPart catalogPart) { if (catalogPart == null) { throw new ArgumentNullException("catalogPart"); } PartChromeType effectiveChromeType = this.Zone.GetEffectiveChromeType(catalogPart); Style style = this.CreateCatalogPartChromeStyle(catalogPart, effectiveChromeType); if (!style.IsEmpty) { style.AddAttributesToRender(writer, this.Zone); } writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Table); switch (effectiveChromeType) { case PartChromeType.TitleOnly: case PartChromeType.TitleAndBorder: { writer.RenderBeginTag(HtmlTextWriterTag.Tr); Style partTitleStyle = this.Zone.PartTitleStyle; if (!partTitleStyle.IsEmpty) { partTitleStyle.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Td); this.RenderTitle(writer, catalogPart); writer.RenderEndTag(); writer.RenderEndTag(); break; } } if (catalogPart.ChromeState != PartChromeState.Minimized) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); Style partStyle = this.Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, this.Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Td); this.RenderPartContents(writer, catalogPart); this.RenderItems(writer, catalogPart); writer.RenderEndTag(); writer.RenderEndTag(); } writer.RenderEndTag(); }
protected virtual void OnRenderCalendarCell(HtmlTextWriter writer, Style style, string text, string title, bool hasButton, string eventArgument, CalendarDay dayInfo) { style.AddAttributesToRender(writer, this); writer.RenderBeginTag(HtmlTextWriterTag.Td); //Fix for displaying correct Hindi numbers //when the page is not in RTL mode. if (IsRightToLeftCulture) { text = toFarsi.Convert(text); title = toFarsi.Convert(title); } if (hasButton) { var args = new RenderCalendarCellArgs(writer, style, dayInfo, eventArgument, text, title); //Only raise event for days rendering if (dayInfo != null) { RaiseRenderCalendarCell(args); } if (!args.Handled) { Color foreColor = style.ForeColor; writer.Write("<a href=\""); writer.Write(this.Page.ClientScript.GetPostBackClientHyperlink(this, eventArgument, true)); writer.Write("\" style=\"color:"); writer.Write(foreColor.IsEmpty ? this.defaultButtonColorText : ColorTranslator.ToHtml(foreColor)); if (!string.IsNullOrEmpty(title)) { writer.Write("\" title=\""); writer.Write(title); } writer.Write("\">"); writer.Write(text); writer.Write("</a>"); } } else { writer.Write(text); } writer.RenderEndTag(); }
private void RenderPlaceHolder(SingleViewRenderingContext renderingContext, Style style, PlaceHolder placeHolder, string cssClass) { ScriptUtility.Instance.RegisterElementForBorderSpans(renderingContext.Control, "#" + placeHolder.ClientID + " > *:first"); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Tr); // begin tr if (string.IsNullOrEmpty(style.CssClass)) { if (placeHolder.Controls.Count > 0) { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass); } else { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass + " " + CssClassEmpty); } } else { if (placeHolder.Controls.Count > 0) { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, style.CssClass); } else { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, style.CssClass + " " + CssClassEmpty); } } renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td); // begin td renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, placeHolder.ClientID); style.AddAttributesToRender(renderingContext.Writer); if (string.IsNullOrEmpty(style.CssClass)) { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass); } renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); // begin outer div renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassContent); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Div); // begin content div placeHolder.RenderControl(renderingContext.Writer); renderingContext.Writer.RenderEndTag(); // end content div renderingContext.Writer.RenderEndTag(); // end outer div renderingContext.Writer.RenderEndTag(); // end td renderingContext.Writer.RenderEndTag(); // end tr }
private void RenderTitle(HtmlTextWriter writer, EditorPart editorPart) { string displayTitle = editorPart.DisplayTitle; if (String.IsNullOrEmpty(displayTitle)) { return; } // Apply TitleStyle to the Legend TableItemStyle titleTableItemStyle = Zone.PartTitleStyle; // PERF: Cache this, since it is needed for every EditorPart in the zone if (_titleTextStyle == null) { // Need to copy the TableItemStyle to a plain Style, since we are going to apply it to // the <legend> tag, which is not a table item. We ignore the horizontal align, // vertical align, and nowrap properties. Style style = new Style(); style.CopyFrom(titleTableItemStyle); _titleTextStyle = style; } if (!_titleTextStyle.IsEmpty) { _titleTextStyle.AddAttributesToRender(writer, Zone); } string description = editorPart.Description; if (!String.IsNullOrEmpty(description)) { writer.AddAttribute(HtmlTextWriterAttribute.Title, description); } string accessKey = editorPart.AccessKey; if (!String.IsNullOrEmpty(accessKey)) { writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey); } writer.RenderBeginTag(HtmlTextWriterTag.Legend); writer.Write(displayTitle); writer.RenderEndTag(); // Legend }
private void RenderEmptyZoneText(HtmlTextWriter writer) { string emptyZoneText = this.EmptyZoneText; if (!string.IsNullOrEmpty(emptyZoneText)) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); Style emptyZoneTextStyle = base.EmptyZoneTextStyle; if (!emptyZoneTextStyle.IsEmpty) { emptyZoneTextStyle.AddAttributesToRender(writer, this); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(emptyZoneText); writer.RenderEndTag(); writer.RenderEndTag(); } }
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(); }
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"); }
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); }
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(); }
protected void RenderDropDownMenuItem(HtmlTextWriter writer, MenuItem item, string parentSubmenuClientId, int index) { var hasChildren = item.ChildItems.Count > 0; var submenuClientId = parentSubmenuClientId + "_" + index; DynamicMenuItemStyle.AddAttributesToRender(writer); if (item.Text != "__separator__") { var onmouseover = "WebForm_AppendToClassName(this, '" + DynamicHoverStyle.RegisteredCssClass + "');"; if (hasChildren) { onmouseover += "IZWebFileManager_MouseHover(this, event, '" + submenuClientId + "');"; } writer.AddAttribute("onmouseover", onmouseover); var onmouseout = "WebForm_RemoveClassName(this, '" + DynamicHoverStyle.RegisteredCssClass + "');"; if (hasChildren) { onmouseout += "IZWebFileManager_MouseOut(this, event, '" + submenuClientId + "');"; } writer.AddAttribute("onmouseout", onmouseout); writer.AddAttribute("onclick", "IZWebFileManager_HideElement('" + parentSubmenuClientId + "')"); } writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "1px 0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "relative"); writer.RenderBeginTag(HtmlTextWriterTag.Div); renderDynamicItem(writer, item, index); if (hasChildren) { writer.AddStyleAttribute(IsRightToLeft ? "left" : "right", "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Top, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute"); writer.RenderBeginTag(HtmlTextWriterTag.Div); RenderDropDownMenu(writer, item.ChildItems, submenuClientId); writer.RenderEndTag(); } writer.RenderEndTag(); }
// PERF: Implement RenderTitleText() without using server controls private void RenderTitleText(HtmlTextWriter writer, WebPart webPart) { // PERF: Cache this, since it is needed for every WebPart in the zone if (_titleTextStyle == null) { _titleTextStyle = CreateTitleTextStyle(Zone.PartTitleStyle); } if (!_titleTextStyle.IsEmpty) { _titleTextStyle.AddAttributesToRender(writer, Zone); } // Render "DisplayTitle - Description" as tooltip (VSWhidbey 367041) writer.AddAttribute(HtmlTextWriterAttribute.Title, GenerateDescriptionText(webPart), true); // string url = webPart.TitleUrl; string text = GenerateTitleText(webPart); if (!String.IsNullOrEmpty(url) && !DragDropEnabled) { writer.AddAttribute(HtmlTextWriterAttribute.Href, Zone.ResolveClientUrl(url)); writer.RenderBeginTag(HtmlTextWriterTag.A); } else { writer.RenderBeginTag(HtmlTextWriterTag.Span); } writer.WriteEncodedText(text); writer.RenderEndTag(); // A || Span // PERF: Always render even if no verbs will be rendered writer.Write(" "); }
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 }
public virtual void RenderWebPart(HtmlTextWriter writer, WebPart webPart) { if (webPart == null) { throw new ArgumentNullException("webPart"); } bool vertical = (Zone.LayoutOrientation == Orientation.Vertical); PartChromeType chromeType = Zone.GetEffectiveChromeType(webPart); Style partChromeStyle = CreateWebPartChromeStyle(webPart, chromeType); // if (!partChromeStyle.IsEmpty) { partChromeStyle.AddAttributesToRender(writer, Zone); } // Render CellPadding=2 so there is a 2 pixel gap between the border and the title/body // of the WebPart. Can't render CellSpacing=2, since we want the backcolor of the title // bar to fill the title bar, and backcolor is not rendered in the CellSpacing. writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); if (vertical) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } else if (webPart.ChromeState != PartChromeState.Minimized) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%"); } if (Zone.RenderClientScript) { writer.AddAttribute(HtmlTextWriterAttribute.Id, GetWebPartChromeClientID(webPart)); } if (!_designMode && webPart.Hidden && WebPartManager != null && !WebPartManager.DisplayMode.ShowHiddenWebParts) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Table); if (chromeType == PartChromeType.TitleOnly || chromeType == PartChromeType.TitleAndBorder) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // PERF: Cache this, since it is needed for every WebPart in the zone if (_titleStyleWithoutFontOrAlign == null) { _titleStyleWithoutFontOrAlign = CreateTitleStyleWithoutFontOrAlign(Zone.PartTitleStyle); } // Need to apply title style here (at least backcolor and border) so the backcolor // and border include the cell padding on the td. // Should not apply font style here, since we don't want verbs to use this // font style. In IE compat mode, the font style would not be inherited anyway, // But in IE strict mode the font style would be inherited. if (!_titleStyleWithoutFontOrAlign.IsEmpty) { _titleStyleWithoutFontOrAlign.AddAttributesToRender(writer, Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderTitleBar(writer, webPart); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } // Render the contents of minimized WebParts with display:none, instead of not rendering // the contents at all. The contents may need to be rendered for client-side connections // or other client-side features. Also allows child controls to maintain their postback // values between requests while the WebPart is minimized. if (webPart.ChromeState == PartChromeState.Minimized) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (!vertical) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); } Style partStyle = Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, Zone); } // Add some extra padding around the WebPart contents (VSWhidbey 324397) writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, Zone.PartChromePadding.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderPartContents(writer, webPart); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr writer.RenderEndTag(); // Table }
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) }
public HtmlAttributeManager Style(Style style) { style.AddAttributesToRender(Writer); return this; }
public virtual void RenderCatalogPart(HtmlTextWriter writer, CatalogPart catalogPart) { if (catalogPart == null) { throw new ArgumentNullException("catalogPart"); } PartChromeType chromeType = Zone.GetEffectiveChromeType(catalogPart); Style partChromeStyle = CreateCatalogPartChromeStyle(catalogPart, chromeType); // if (!partChromeStyle.IsEmpty) { partChromeStyle.AddAttributesToRender(writer, Zone); } writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); // Use CellPadding=2 to match WebPartChrome (VSWhidbey 324397) writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); writer.RenderBeginTag(HtmlTextWriterTag.Table); if (chromeType == PartChromeType.TitleOnly || chromeType == PartChromeType.TitleAndBorder) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Can apply PartTitleStyle directly, since the title bar doesn't contain a nested table Style partTitleStyle = Zone.PartTitleStyle; if (!partTitleStyle.IsEmpty) { partTitleStyle.AddAttributesToRender(writer, Zone); } writer.RenderBeginTag(HtmlTextWriterTag.Td); RenderTitle(writer, catalogPart); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } if (catalogPart.ChromeState != PartChromeState.Minimized) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); Style partStyle = Zone.PartStyle; if (!partStyle.IsEmpty) { partStyle.AddAttributesToRender(writer, Zone); } // For now, I don't think we should render extra padding here. People writing custom // CatalogParts can add a margin to their contents if they want it. This is not the // same as the WebPartChrome case, since for WebParts we allow people to use ServerControls, // that will likely not have a margin. (VSWhidbey 324397) // writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "5px"); writer.RenderBeginTag(HtmlTextWriterTag.Td); // RenderPartContents(writer, catalogPart); RenderItems(writer, catalogPart); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } writer.RenderEndTag(); // Table }
private void RenderMenuPopup(HtmlTextWriter writer, ICollection verbs, string clientID, WebPart associatedWebPart, WebPartManager webPartManager) { writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "Menu"); writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); writer.RenderBeginTag(HtmlTextWriterTag.Div); bool isEmpty = true; WebPartMenuStyle menuPopupStyle = this._menuUser.MenuPopupStyle; if (menuPopupStyle != null) { menuPopupStyle.AddAttributesToRender(writer, this._menuUser as WebControl); isEmpty = menuPopupStyle.Width.IsEmpty; } else { writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse"); } if (isEmpty) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); bool isEnabled = associatedWebPart.Zone.IsEnabled; foreach (WebPartVerb verb in verbs) { string description; writer.RenderBeginTag(HtmlTextWriterTag.Div); if (associatedWebPart != null) { description = string.Format(CultureInfo.CurrentCulture, verb.Description, new object[] { associatedWebPart.DisplayTitle }); } else { description = verb.Description; } if (description.Length != 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, description); } bool flag3 = isEnabled && verb.Enabled; if (verb is WebPartHelpVerb) { string str2 = associatedWebPart.ResolveClientUrl(associatedWebPart.HelpUrl); writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (flag3) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ShowHelp('" + Util.QuoteJScriptString(str2) + "', " + ((int)associatedWebPart.HelpMode).ToString(CultureInfo.InvariantCulture) + ")"); } } else if (verb is WebPartExportVerb) { string exportUrl = webPartManager.GetExportUrl(associatedWebPart); writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (flag3) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ExportWebPart('" + Util.QuoteJScriptString(exportUrl) + ((associatedWebPart.ExportMode == WebPartExportMode.All) ? "', true, false)" : "', false, false)")); } } else { string postBackTarget = this._menuUser.PostBackTarget; writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (flag3) { string eventArgument = verb.EventArgument; if (associatedWebPart != null) { eventArgument = verb.GetEventArgument(associatedWebPart.ID); } string str6 = null; if (!string.IsNullOrEmpty(eventArgument)) { str6 = "document.body.__wpm.SubmitPage('" + Util.QuoteJScriptString(postBackTarget) + "', '" + Util.QuoteJScriptString(eventArgument) + "');"; this._menuUser.Page.ClientScript.RegisterForEventValidation(postBackTarget, eventArgument); } string str7 = null; if (!string.IsNullOrEmpty(verb.ClientClickHandler)) { str7 = "document.body.__wpm.Execute('" + Util.QuoteJScriptString(Util.EnsureEndWithSemiColon(verb.ClientClickHandler)) + "')"; } string str8 = string.Empty; if ((str6 != null) && (str7 != null)) { str8 = "if(" + str7 + "){" + str6 + "}"; } else if (str6 != null) { str8 = str6; } else if (str7 != null) { str8 = str7; } if (verb is WebPartCloseVerb) { ProviderConnectionPointCollection providerConnectionPoints = webPartManager.GetProviderConnectionPoints(associatedWebPart); if (((providerConnectionPoints != null) && (providerConnectionPoints.Count > 0)) && webPartManager.Connections.ContainsProvider(associatedWebPart)) { str8 = "if(document.body.__wpmCloseProviderWarning.length == 0 || confirm(document.body.__wpmCloseProviderWarning)){" + str8 + "}"; } } else if (verb is WebPartDeleteVerb) { str8 = "if(document.body.__wpmDeleteWarning.length == 0 || confirm(document.body.__wpmDeleteWarning)){" + str8 + "}"; } writer.AddAttribute(HtmlTextWriterAttribute.Onclick, str8); } } string str9 = "menuItem"; if (!verb.Enabled) { if (associatedWebPart.Zone.RenderingCompatibility < VersionUtil.Framework40) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } else if (!string.IsNullOrEmpty(WebControl.DisabledCssClass)) { str9 = WebControl.DisabledCssClass + " " + str9; } } writer.AddAttribute(HtmlTextWriterAttribute.Class, str9); writer.RenderBeginTag(HtmlTextWriterTag.A); string imageUrl = verb.ImageUrl; if (imageUrl.Length != 0) { imageUrl = this._menuUser.UrlResolver.ResolveClientUrl(imageUrl); } else if (verb.Checked) { imageUrl = this._menuUser.CheckImageUrl; if (imageUrl.Length == 0) { imageUrl = DefaultCheckImageUrl; } } else { imageUrl = webPartManager.SpacerImageUrl; } writer.AddAttribute(HtmlTextWriterAttribute.Src, imageUrl); writer.AddAttribute(HtmlTextWriterAttribute.Alt, description, true); writer.AddAttribute(HtmlTextWriterAttribute.Width, "16"); writer.AddAttribute(HtmlTextWriterAttribute.Height, "16"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none"); writer.AddStyleAttribute("vertical-align", "middle"); if (verb.Checked) { Style checkImageStyle = this._menuUser.CheckImageStyle; if (checkImageStyle != null) { checkImageStyle.AddAttributesToRender(writer, this._menuUser as WebControl); } } writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.Write(" "); writer.Write(verb.Text); writer.Write(" "); writer.RenderEndTag(); writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// User By Control Designer /// </summary> /// <param name="writer"></param> public void RenderButton(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 the style, if (ControlStyleCreated) { Style controlStyle = ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); renderWrapper = true; } } // And Enabled if (!IsEnabled) { 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 = string.Format("PostCommand_{0}()", ClientID); // 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) { attribs.Remove("onclick"); } if (attribs.Count != 0) { attribs.AddAttributes(writer); renderWrapper = true; } if (val != null) { attribs["value"] = val; } } string text = Text; string clientID = base.ClientID; //ClientID; RenderInputTag(writer, clientID, onClick, text); }
/// <summary> /// User By Control Designer /// </summary> /// <param name="writer"></param> public void RenderDropDownList(HtmlTextWriter writer) { writer.AddAttribute(HtmlTextWriterAttribute.Id, "span_" + this.ClientID); // render begin tag of wrapper SPAN writer.RenderBeginTag(HtmlTextWriterTag.Span); 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 the style, if (ControlStyleCreated) { Style controlStyle = ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); renderWrapper = true; } } // And Enabled if (!IsEnabled) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); renderWrapper = true; } // And ToolTip string toolTip = ToolTip; if (toolTip.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, toolTip); renderWrapper = true; } string onSelectedIndexChanged = string.Format("PostCommand_{0}()", base.ClientID); // 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 onSelectedIndexChanged = attribs["onchange"]; if (onSelectedIndexChanged != null) { // onClick = System.Web.UI.Design.Util.EnsureEndWithSemiColon(onClick); attribs.Remove("onchange"); } if (attribs.Count != 0) { attribs.AddAttributes(writer); renderWrapper = true; } if (val != null) { attribs["value"] = val; } } string clientID = base.ClientID; //ClientID; RenderSelectTag(writer, clientID, onSelectedIndexChanged); // render end tag of wrapper SPAN writer.RenderEndTag(); }
/// <summary> /// User By Control Designer /// </summary> /// <param name="writer"></param> public void RenderCheckBox(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 the style, if (ControlStyleCreated) { Style controlStyle = ControlStyle; if (!controlStyle.IsEmpty) { controlStyle.AddAttributesToRender(writer, this); renderWrapper = true; } } // And Enabled if (!IsEnabled) { 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 = string.Format("PostCommand_{0}()", iclientID); // 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 = System.Web.UI.Design.Util.EnsureEndWithSemiColon(onClick); attribs.Remove("onclick"); } if (attribs.Count != 0) { attribs.AddAttributes(writer); renderWrapper = true; } if (val != null) { attribs["value"] = val; } } writer.RenderBeginTag(HtmlTextWriterTag.Span); string text = Text; string clientID = iclientID; //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); } writer.RenderEndTag(); }
private void RenderMenuPopup(HtmlTextWriter writer, ICollection verbs, string clientID, WebPart associatedWebPart, WebPartManager webPartManager) { writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID + "Menu"); writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); writer.RenderBeginTag(HtmlTextWriterTag.Div); bool popupSpansFullExtent = true; WebPartMenuStyle menuStyle = _menuUser.MenuPopupStyle; if (menuStyle != null) { menuStyle.AddAttributesToRender(writer, _menuUser as WebControl); popupSpansFullExtent = menuStyle.Width.IsEmpty; } else { // generate attributes corresponding to defaults on WebPartMenuStyle writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse"); } if (popupSpansFullExtent) { writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); bool isParentEnabled = associatedWebPart.Zone.IsEnabled; foreach (WebPartVerb verb in verbs) { Debug.Assert(verb != null); writer.RenderBeginTag(HtmlTextWriterTag.Div); string alt; if (associatedWebPart != null) { alt = String.Format(CultureInfo.CurrentCulture, verb.Description, associatedWebPart.DisplayTitle); } else { alt = verb.Description; } if (alt.Length != 0) { writer.AddAttribute(HtmlTextWriterAttribute.Title, alt); } bool isEnabled = isParentEnabled && verb.Enabled; // Special case help, export, etc. if (verb is WebPartHelpVerb) { Debug.Assert(associatedWebPart != null); string resolvedHelpUrl = ((IUrlResolutionService)associatedWebPart).ResolveClientUrl(associatedWebPart.HelpUrl); writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (isEnabled) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ShowHelp('" + Util.QuoteJScriptString(resolvedHelpUrl) + "', " + ((int)associatedWebPart.HelpMode).ToString(CultureInfo.InvariantCulture) + ")"); } } else if (verb is WebPartExportVerb) { Debug.Assert(associatedWebPart != null); string exportUrl = webPartManager.GetExportUrl(associatedWebPart); writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (isEnabled) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "document.body.__wpm.ExportWebPart('" + Util.QuoteJScriptString(exportUrl) + ((associatedWebPart.ExportMode == WebPartExportMode.All) ? "', true, false)" : "', false, false)")); } } else { string target = _menuUser.PostBackTarget; writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)"); if (isEnabled) { string eventArgument = verb.EventArgument; if (associatedWebPart != null) { eventArgument = verb.GetEventArgument(associatedWebPart.ID); } string submitScript = null; if (!String.IsNullOrEmpty(eventArgument)) { submitScript = "document.body.__wpm.SubmitPage('" + Util.QuoteJScriptString(target) + "', '" + Util.QuoteJScriptString(eventArgument) + "');"; _menuUser.Page.ClientScript.RegisterForEventValidation(target, eventArgument); } string clientClickScript = null; if (!String.IsNullOrEmpty(verb.ClientClickHandler)) { clientClickScript = "document.body.__wpm.Execute('" + Util.QuoteJScriptString(Util.EnsureEndWithSemiColon(verb.ClientClickHandler)) + "')"; } // There must be either an EventArgument or a ClientClickHandler Debug.Assert(submitScript != null || clientClickScript != null); string onclick = String.Empty; if (submitScript != null && clientClickScript != null) { onclick = "if(" + clientClickScript + "){" + submitScript + "}"; } else if (submitScript != null) { onclick = submitScript; } else if (clientClickScript != null) { onclick = clientClickScript; } if (verb is WebPartCloseVerb) { Debug.Assert(associatedWebPart != null); // PERF: First check if this WebPart even has provider connection points ProviderConnectionPointCollection connectionPoints = webPartManager.GetProviderConnectionPoints(associatedWebPart); if (connectionPoints != null && connectionPoints.Count > 0 && webPartManager.Connections.ContainsProvider(associatedWebPart)) { onclick = "if(document.body.__wpmCloseProviderWarning.length == 0 || " + "confirm(document.body.__wpmCloseProviderWarning)){" + onclick + "}"; } } else if (verb is WebPartDeleteVerb) { onclick = "if(document.body.__wpmDeleteWarning.length == 0 || " + "confirm(document.body.__wpmDeleteWarning)){" + onclick + "}"; } writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick); } } string disabledClass = "menuItem"; if (!verb.Enabled) { if (associatedWebPart.Zone.RenderingCompatibility < VersionUtil.Framework40) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } else if (!String.IsNullOrEmpty(WebControl.DisabledCssClass)) { disabledClass = WebControl.DisabledCssClass + " " + disabledClass; } } writer.AddAttribute(HtmlTextWriterAttribute.Class, disabledClass); writer.RenderBeginTag(HtmlTextWriterTag.A); string img = verb.ImageUrl; if (img.Length != 0) { img = _menuUser.UrlResolver.ResolveClientUrl(img); } else { if (verb.Checked) { img = _menuUser.CheckImageUrl; if (img.Length == 0) { img = DefaultCheckImageUrl; } } else { img = webPartManager.SpacerImageUrl; } } writer.AddAttribute(HtmlTextWriterAttribute.Src, img); writer.AddAttribute(HtmlTextWriterAttribute.Alt, alt, true); writer.AddAttribute(HtmlTextWriterAttribute.Width, "16"); writer.AddAttribute(HtmlTextWriterAttribute.Height, "16"); writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none"); writer.AddStyleAttribute("vertical-align", "middle"); if (verb.Checked) { Style checkImageStyle = _menuUser.CheckImageStyle; if (checkImageStyle != null) { checkImageStyle.AddAttributesToRender(writer, _menuUser as WebControl); } } writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // Img writer.Write(" "); writer.Write(verb.Text); writer.Write(" "); writer.RenderEndTag(); // A writer.RenderEndTag(); // Div } writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr writer.RenderEndTag(); // Table writer.RenderEndTag(); // Div }