当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTextWriter.AddStyleAttribute方法代码示例

本文整理汇总了C#中HtmlTextWriter.AddStyleAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.AddStyleAttribute方法的具体用法?C# HtmlTextWriter.AddStyleAttribute怎么用?C# HtmlTextWriter.AddStyleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlTextWriter的用法示例。


在下文中一共展示了HtmlTextWriter.AddStyleAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			base.AddAttributesToRender (w);
			
			string image = BackImageUrl;
			if (image != "") {
				image = ResolveClientUrl (image);
#if !NET_2_0 // see HtmlTextWriter.WriteStyleAttribute(string, string, bool) 
				image = String.Concat ("url(", image, ")");
#endif
				w.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, image);
			}

			if (!String.IsNullOrEmpty (DefaultButton) && Page != null) {
				Control button = FindControl (DefaultButton);
				if (button == null || !(button is IButtonControl))
					throw new InvalidOperationException (String.Format ("The DefaultButton of '{0}' must be the ID of a control of type IButtonControl.", ID));

				Page.ClientScript.RegisterWebFormClientScript ();

				w.AddAttribute ("onkeypress",
						"javascript:return " + Page.WebFormScriptReference + ".WebForm_FireDefaultButton(event, '" + button.ClientID + "')");
			}

			if (Direction != ContentDirection.NotSet) {
				w.AddAttribute (HtmlTextWriterAttribute.Dir, Direction == ContentDirection.RightToLeft ? "rtl" : "ltr", false);
			}

			switch (ScrollBars) {
			case ScrollBars.Auto:
				w.AddStyleAttribute (HtmlTextWriterStyle.Overflow, "auto");
				break;
			case ScrollBars.Both:
				w.AddStyleAttribute (HtmlTextWriterStyle.Overflow, "scroll");
				break;
			case ScrollBars.Horizontal:
				w.AddStyleAttribute (HtmlTextWriterStyle.OverflowX, "scroll");
				break;
			case ScrollBars.Vertical:
				w.AddStyleAttribute (HtmlTextWriterStyle.OverflowY, "scroll");
				break;
			}


			if (!Wrap) {
				w.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
			}

			string align = "";

			switch (HorizontalAlign) {
			case HorizontalAlign.Center: align = "center"; break;
			case HorizontalAlign.Justify: align = "justify"; break;
			case HorizontalAlign.Left: align = "left"; break;
			case HorizontalAlign.Right: align = "right"; break;
			}

			if (align != "")
				w.AddStyleAttribute (HtmlTextWriterStyle.TextAlign, align);
		}
开发者ID:LevNNN,项目名称:mono,代码行数:60,代码来源:Panel.cs

示例2: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter writer)
		{
			const string ListStyleType = "list-style-type";
			const string ListStyleImage = "list-style-image";
			
			bool isNumeric = false;
			switch (BulletStyle)
			{
				case BulletStyle.NotSet:
					break;
				
				case BulletStyle.Numbered:
					writer.AddStyleAttribute (ListStyleType, "decimal");
					isNumeric = true;
					break;
				
				case BulletStyle.LowerAlpha:
					writer.AddStyleAttribute (ListStyleType, "lower-alpha");
					isNumeric = true;
					break;
				
				case BulletStyle.UpperAlpha:
					writer.AddStyleAttribute (ListStyleType, "upper-alpha");
					isNumeric = true;
					break;
				
				case BulletStyle.LowerRoman:
					writer.AddStyleAttribute (ListStyleType, "lower-roman");
					isNumeric = true;
					break;
				
				case BulletStyle.UpperRoman:
					writer.AddStyleAttribute (ListStyleType, "upper-roman");
					isNumeric = true;
					break;

				case BulletStyle.Disc:
					writer.AddStyleAttribute (ListStyleType, "disc");
					break;
				
				case BulletStyle.Circle:
					writer.AddStyleAttribute (ListStyleType, "circle");
					break;
				
				case BulletStyle.Square:
					writer.AddStyleAttribute (ListStyleType, "square");
					break;
								
				case BulletStyle.CustomImage:
					writer.AddStyleAttribute (ListStyleImage, "url(" + ResolveClientUrl (BulletImageUrl) + ")");
					break;
			}

			if (isNumeric && FirstBulletNumber != 1)
				writer.AddAttribute ("start", FirstBulletNumber.ToString ());
			
			base.AddAttributesToRender (writer);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:58,代码来源:BulletedList.cs

示例3: RenderNode

 		void RenderNode (HtmlTextWriter writer, TreeNode node, int level, ArrayList levelLines, bool hasPrevious, bool hasNext)
		{
			if (node.PopulateOnDemand && node.HadChildrenBeforePopulating)
				throw new InvalidOperationException ("PopulateOnDemand cannot be set to true on a node that already has children.");
			
			DecorateNode(node);
			
			string nodeImage;
			bool clientExpand = EnableClientScript && Events [TreeNodeCollapsedEvent] == null && Events [TreeNodeExpandedEvent] == null;
			ImageStyle imageStyle = GetImageStyle ();
			bool renderChildNodes = node.Expanded.HasValue && node.Expanded.Value;
			
			if (clientExpand && !renderChildNodes)
				renderChildNodes = (!node.PopulateOnDemand || node.Populated);
				
			bool hasChildNodes;
			
			if (renderChildNodes)
				hasChildNodes = node.ChildNodes.Count > 0;
			else
				hasChildNodes = (node.PopulateOnDemand && !node.Populated) || node.ChildNodes.Count > 0;
				
			writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0", false);
			writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0", false);
			writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0");
			writer.RenderBeginTag (HtmlTextWriterTag.Table);

			Unit nodeSpacing = GetNodeSpacing (node);
#if !NET_4_0
			if (nodeSpacing != Unit.Empty && (node.Depth > 0 || node.Index > 0))
				RenderMenuItemSpacing (writer, nodeSpacing);
#endif
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
			
			// Vertical lines from previous levels

			nodeImage = GetNodeImageUrl ("i", imageStyle);
			for (int n=0; n<level; n++) {
				writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.AddStyleAttribute (HtmlTextWriterStyle.Width, NodeIndent + "px");
				writer.AddStyleAttribute (HtmlTextWriterStyle.Height, "1px");
				writer.RenderBeginTag (HtmlTextWriterTag.Div);
				if (ShowLines && levelLines [n] != null) {
					writer.AddAttribute (HtmlTextWriterAttribute.Src, nodeImage);
					writer.AddAttribute (HtmlTextWriterAttribute.Alt, String.Empty, false);
					writer.RenderBeginTag (HtmlTextWriterTag.Img);
					writer.RenderEndTag ();
				}
				writer.RenderEndTag ();
				writer.RenderEndTag ();	// TD
			}
			
			// Node image + line
			bool showExpandCollapse = ShowExpandCollapse;
			bool showLines = ShowLines;
			if (showExpandCollapse || showLines) {
				bool buttonImage = false;
				string tooltip = String.Empty;
				string shape = String.Empty;
				
				if (showLines) {
					if (hasPrevious && hasNext)
						shape = "t";
					else if (hasPrevious && !hasNext)
						shape = "l";
					else if (!hasPrevious && hasNext)
						shape = "r";
					else
						shape = "dash";
				}
				
				if (showExpandCollapse) {
					if (hasChildNodes) {
						buttonImage = true;
						if (node.Expanded.HasValue && node.Expanded.Value)
							shape += "minus";
						else
							shape += "plus";
						tooltip = GetNodeImageToolTip (!(node.Expanded.HasValue && node.Expanded.Value), node.Text);
					} else if (!showLines)
						shape = "noexpand";
				}

				if (!String.IsNullOrEmpty (shape)) {
					nodeImage = GetNodeImageUrl (shape, imageStyle);
					writer.RenderBeginTag (HtmlTextWriterTag.Td);	// TD
					
					if (buttonImage) {
						if (!clientExpand || (!PopulateNodesFromClient && node.PopulateOnDemand && !node.Populated))
							writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientEvent (node, "ec"));
						else
							writer.AddAttribute (HtmlTextWriterAttribute.Href, GetClientExpandEvent(node));
						writer.RenderBeginTag (HtmlTextWriterTag.A);	// Anchor
					}

					// tooltip is 'HtmlAttributeEncoded'
					writer.AddAttribute (HtmlTextWriterAttribute.Alt, tooltip);

					if (buttonImage && clientExpand)
						writer.AddAttribute (HtmlTextWriterAttribute.Id, GetNodeClientId (node, "img"));
//.........这里部分代码省略.........
开发者ID:tgiphil,项目名称:mono,代码行数:101,代码来源:TreeView.cs

示例4: RenderBeginTag

		public override void RenderBeginTag (HtmlTextWriter writer)
		{
			string skipLinkText = SkipLinkText;
			
			if (!String.IsNullOrEmpty (skipLinkText)) {
				writer.AddAttribute (HtmlTextWriterAttribute.Href, "#" + ClientID + "_SkipLink");
				writer.RenderBeginTag (HtmlTextWriterTag.A);

				ClientScriptManager csm = new ClientScriptManager (null);
				
				writer.AddAttribute (HtmlTextWriterAttribute.Alt, skipLinkText);
				writer.AddAttribute (HtmlTextWriterAttribute.Src, csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif"));
				writer.AddAttribute (HtmlTextWriterAttribute.Height, "0");
				writer.AddAttribute (HtmlTextWriterAttribute.Width, "0");
				writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
				writer.RenderBeginTag (HtmlTextWriterTag.Img);
				
				writer.RenderEndTag (); // img
				writer.RenderEndTag (); // a
			}
			base.RenderBeginTag (writer);
		}
开发者ID:tgiphil,项目名称:mono,代码行数:22,代码来源:TreeView.cs

示例5: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter writer)
		{
			base.AddAttributesToRender (writer);
			// src is always present, even if empty, in 2.0
			writer.AddAttribute (HtmlTextWriterAttribute.Src, ResolveClientUrl (ImageUrl));
			string s = AlternateText;
			if ((s.Length > 0) || GenerateEmptyAlternateText)
				writer.AddAttribute (HtmlTextWriterAttribute.Alt, s);
			s = DescriptionUrl;
			if (s.Length > 0)
				writer.AddAttribute (HtmlTextWriterAttribute.Longdesc, ResolveClientUrl (s));

			switch (ImageAlign) {
				case ImageAlign.Left:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "left", false);
					break;
				case ImageAlign.Right:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "right", false);
					break;
				case ImageAlign.Baseline:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "baseline", false);
					break;
				case ImageAlign.Top:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "top", false);
					break;
				case ImageAlign.Middle:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "middle", false);
					break;
				case ImageAlign.Bottom:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "bottom", false);
					break;
				case ImageAlign.AbsBottom:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "absbottom", false);
					break;
				case ImageAlign.AbsMiddle:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "absmiddle", false);
					break;
				case ImageAlign.TextTop:
					writer.AddAttribute (HtmlTextWriterAttribute.Align, "texttop", false);
					break;
			}
#if BUG_78875_FIXED
			if (Context.Request.Browser.SupportsCss)
#endif
#if !NET_4_0
			if (BorderWidth.IsEmpty)
				writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
#endif
		}
开发者ID:nobled,项目名称:mono,代码行数:49,代码来源:Image.cs

示例6: AddAttributesToRender

		// for 2.0: not XHTML attributes must be registered with RegisterExpandoAttribute 
		// when it will be implemented, in this case WebUIValidation_2.0.js muist be refactored
		protected override void AddAttributesToRender(HtmlTextWriter writer) {
			base.AddAttributesToRender (writer);

#if NET_2_0
			if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel (ValidationGroup)) {
#else
			if (EnableClientScript && pre_render_called && Page.AreValidatorsUplevel ()) {
#endif
				/* force an ID here if we weren't assigned one */
				if (ID == null)
					writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
#if NET_2_0
				if (ValidationGroup != String.Empty)
					RegisterExpandoAttribute (ClientID, "validationGroup", ValidationGroup);

				if (HeaderText.Length > 0)
					RegisterExpandoAttribute (ClientID, "headertext", HeaderText);

				if (ShowMessageBox)
					RegisterExpandoAttribute (ClientID, "showmessagebox", "True");

				if (!ShowSummary)
					RegisterExpandoAttribute (ClientID, "showsummary", "False");

				if (DisplayMode != ValidationSummaryDisplayMode.BulletList)
					RegisterExpandoAttribute (ClientID, "displaymode", DisplayMode.ToString ());
#else
				if (HeaderText != "")
					writer.AddAttribute ("headertext", HeaderText);

				if (ShowMessageBox)
					writer.AddAttribute ("showmessagebox", ShowMessageBox.ToString());

				if (ShowSummary == false)
					writer.AddAttribute ("showsummary", ShowSummary.ToString());

				if (DisplayMode != ValidationSummaryDisplayMode.BulletList)
					writer.AddAttribute ("displaymode", DisplayMode.ToString());
#endif

				if (!has_errors)
					writer.AddStyleAttribute ("display", "none");
			}
		}

#if NET_2_0
		internal void RegisterExpandoAttribute (string controlId, string attributeName, string attributeValue) {
			RegisterExpandoAttribute (controlId, attributeName, attributeValue, false);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:51,代码来源:ValidationSummary.cs

示例7: RenderContents

		protected internal override void RenderContents (HtmlTextWriter w)	
		{
			if (HasControls () || HasRenderMethodDelegate ()) {
				base.RenderContents (w);
				return;
			}
			string image_url = ImageUrl;
			if (!String.IsNullOrEmpty (image_url)) {
				string str = ToolTip;
				if (!String.IsNullOrEmpty (str))
					w.AddAttribute (HtmlTextWriterAttribute.Title, str);

				w.AddAttribute (HtmlTextWriterAttribute.Src, ResolveClientUrl (image_url));
				str = Text;
#if !NET_4_0
				if (!String.IsNullOrEmpty (str))
#endif
					w.AddAttribute (HtmlTextWriterAttribute.Alt, str);
#if !NET_4_0
				w.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
#endif
				w.RenderBeginTag (HtmlTextWriterTag.Img);
				w.RenderEndTag ();
			} else
				w.Write (Text);
		}
开发者ID:nobled,项目名称:mono,代码行数:26,代码来源:HyperLink.cs

示例8: RenderBeginTag

            public override void RenderBeginTag(HtmlTextWriter writer, bool staticOnly) {
                ControlRenderingHelper.WriteSkipLinkStart(writer, Menu.RenderingCompatibility, Menu.DesignMode, Menu.SkipLinkText, SpacerImageUrl, Menu.ClientID);

                if (Menu.DesignMode && Menu.IncludeStyleBlock) {
                    // Need to render style block in design mode, since it won't be present
                    CreateStyleBlock().Render(writer);
                }

                // Add expando attributes
                if (Menu.HasAttributes) {
                    foreach (string key in Menu.Attributes.Keys) {
                        writer.AddAttribute(key, Menu.Attributes[key]);
                    }
                }

                // CSS class, including disabled class if it's set
                string cssClass = Menu.CssClass ?? "";
                if (!Menu.Enabled) {
                    cssClass = (cssClass + " " + DisabledCssClass).Trim();
                }
                if (!String.IsNullOrEmpty(cssClass)) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
                }

                // Need to simulate the float done by Javascript when we're in design mode
                if (Menu.DesignMode) {
                    writer.AddStyleAttribute("float", "left");
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Id, Menu.ClientID);
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
            }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:MenuRendererStandards.cs

示例9: WriteStyleAttributes

		void WriteStyleAttributes (HtmlTextWriter writer) 
		{
			string s;
			Color		color;
			BorderStyle	bs;
			Unit		u;

			if (CheckBit ((int) Styles.BackColor)) {
				color = (Color)viewstate["BackColor"];
				if (!color.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color));
			}

			if (CheckBit ((int) Styles.BorderColor)) {
				color = (Color)viewstate["BorderColor"];
				if (!color.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color));
			}

			bool have_width = false;
			if (CheckBit ((int) Styles.BorderWidth)) {
				u = (Unit)viewstate["BorderWidth"];
				if (!u.IsEmpty) {
					if (u.Value > 0)
						have_width = true;
					writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, u.ToString());
				}
			}

			if (CheckBit ((int) Styles.BorderStyle)) {
				bs = (BorderStyle)viewstate["BorderStyle"];
				if (bs != BorderStyle.NotSet) 
					writer.AddStyleAttribute (HtmlTextWriterStyle.BorderStyle, bs.ToString());
				else {
					if (CheckBit ((int) Styles.BorderWidth))
						writer.AddStyleAttribute (HtmlTextWriterStyle.BorderStyle, "solid");
				}
			} else if (have_width) {
				writer.AddStyleAttribute (HtmlTextWriterStyle.BorderStyle, "solid");
			}

			if (CheckBit ((int) Styles.ForeColor)) {
				color = (Color)viewstate["ForeColor"];
				if (!color.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color));
			}

			if (CheckBit ((int) Styles.Height)) {
				u = (Unit)viewstate["Height"];
				if (!u.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.Height, u.ToString());
			}

			if (CheckBit ((int) Styles.Width)) {
				u = (Unit)viewstate["Width"];
				if (!u.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.Width, u.ToString());
			}

			if (CheckBit ((int) Style.Styles.FontAll)) {
				// Fonts are a bit weird
				FontInfo font = Font;
				if (font.Name != string.Empty) {
					s = font.Names[0];
					for (int i = 1; i < font.Names.Length; i++)
						s += "," + font.Names[i];
					writer.AddStyleAttribute (HtmlTextWriterStyle.FontFamily, s);
				}

				if (font.Bold)
					writer.AddStyleAttribute (HtmlTextWriterStyle.FontWeight, "bold");

				if (font.Italic)
					writer.AddStyleAttribute (HtmlTextWriterStyle.FontStyle, "italic");

				if (!font.Size.IsEmpty)
					writer.AddStyleAttribute (HtmlTextWriterStyle.FontSize, font.Size.ToString());

				// These styles are munged into a attribute decoration
				s = string.Empty;

				if (font.Overline)
					s += "overline ";

				if (font.Strikeout)
					s += "line-through ";

				if (font.Underline)
					s += "underline ";

				s = (s != "") ? s : AlwaysRenderTextDecoration ? "none" : "";
				if (s != "")
					writer.AddStyleAttribute (HtmlTextWriterStyle.TextDecoration, s);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:95,代码来源:Style.cs

示例10: RenderContents

		protected internal override void RenderContents (HtmlTextWriter w)
		{
			string skip_id = ClientID + "_SkipLink";
			string altText = SkipLinkText;
			bool needAnchor = !String.IsNullOrEmpty (altText);
			
			if (needAnchor) {
				// Anchor start
				w.AddAttribute (HtmlTextWriterAttribute.Href, "#" + skip_id);
				w.RenderBeginTag (HtmlTextWriterTag.A);

				// Image
				w.AddAttribute (HtmlTextWriterAttribute.Alt, altText);
				w.AddAttribute (HtmlTextWriterAttribute.Height, "0");
				w.AddAttribute (HtmlTextWriterAttribute.Width, "0");
				w.AddAttribute (HtmlTextWriterAttribute.Src, Page.ClientScript.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif"));
				w.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
				w.RenderBeginTag (HtmlTextWriterTag.Img);
				w.RenderEndTag ();

				w.RenderEndTag ();
			}

			base.RenderContents (w);

			if (needAnchor) {
				 w.AddAttribute(HtmlTextWriterAttribute.Id, skip_id);
				 w.RenderBeginTag(HtmlTextWriterTag.A);
				 w.RenderEndTag();
			}
		}
开发者ID:nobled,项目名称:mono,代码行数:31,代码来源:SiteMapPath.cs

示例11: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter writer)
		{
			/* if we're rendering uplevel, add our attributes */
			if (render_uplevel) {
				/* force an ID here if we weren't assigned one */
				if (ID == null)
					writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);

				if (ControlToValidate != String.Empty)
					RegisterExpandoAttribute (ClientID, "controltovalidate", GetControlRenderID (ControlToValidate));

				if (ErrorMessage != String.Empty)
					RegisterExpandoAttribute (ClientID, "errormessage", ErrorMessage, true);

				if (ValidationGroup != String.Empty)
					RegisterExpandoAttribute (ClientID, "validationGroup", ValidationGroup, true);

				if (SetFocusOnError)
					RegisterExpandoAttribute (ClientID, "focusOnError", "t");

				bool enabled = IsEnabled;
				if (!enabled)
					RegisterExpandoAttribute (ClientID, "enabled", "False");

				if (enabled && !IsValid)
					RegisterExpandoAttribute (ClientID, "isvalid", "False");
				else {
					if (Display == ValidatorDisplay.Static)
						writer.AddStyleAttribute ("visibility", "hidden");
					else
						writer.AddStyleAttribute ("display", "none");
				}

				if (Display != ValidatorDisplay.Static)
					RegisterExpandoAttribute (ClientID, "display", Display.ToString ());
			}

			base.AddAttributesToRender (writer);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:39,代码来源:BaseValidator.cs

示例12: RenderItems

            private void RenderItems(HtmlTextWriter writer, bool staticOnly, MenuItemCollection items, int level, bool needsAccessKey) {
                if (level == 1 || level > Menu.StaticDisplayLevels) {  // Render a <UL> to start, and for all dynamic descendents
                    if (Menu.DesignMode && Menu.Orientation == Orientation.Horizontal) {
                        writer.AddStyleAttribute("float", "left");
                    }
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, GetMenuCssClass(level));
                    writer.RenderBeginTag(HtmlTextWriterTag.Ul);
                }

                foreach (MenuItem item in items) {
                    if (Menu.DesignMode && Menu.Orientation == Orientation.Horizontal) {
                        writer.AddStyleAttribute("float", "left");
                        writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Li);

                    needsAccessKey = RenderItem(writer, item, level, GetMenuItemCssClass(item, level), needsAccessKey);

                    if (level < Menu.StaticDisplayLevels) {  // Close off <LI> if we (and our direct descendents) are static
                        writer.RenderEndTag();
                    }

                    if (item.ChildItems.Count > 0 && !IsChildPastMaximumDepth(item) && item.Enabled) {
                        if (level < Menu.StaticDisplayLevels || !staticOnly) {
                            RenderItems(writer, staticOnly, item.ChildItems, level + 1, needsAccessKey);
                        }
                    }

                    if (level >= Menu.StaticDisplayLevels) {  // Close off <LI> if we (or our direct descendents) are dynamic
                        writer.RenderEndTag();
                    }
                }

                if (level == 1 || level > Menu.StaticDisplayLevels) {
                    writer.RenderEndTag();
                }
            }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:37,代码来源:MenuRendererStandards.cs

示例13: RenderItem

            private bool RenderItem(HtmlTextWriter writer, MenuItem item, int level, string cssClass, bool needsAccessKey) {
                RenderItemPreSeparator(writer, item);

                if (Menu.DesignMode && Menu.Orientation == Orientation.Horizontal) {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
                }
                needsAccessKey = RenderItemLinkAttributes(writer, item, level, cssClass, needsAccessKey);
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                RenderItemIcon(writer, item);
                item.RenderText(writer);
                // popout image is in the A's background css
                writer.RenderEndTag();  // </a>

                RenderItemPostSeparator(writer, item);

                return needsAccessKey;
            }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:MenuRendererStandards.cs

示例14: RenderMenuItemSpacing

		void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing)
		{
#if !NET_4_0
			writer.AddStyleAttribute (HtmlTextWriterStyle.Height, itemSpacing.ToString ());
#endif
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
			writer.RenderBeginTag (HtmlTextWriterTag.Td);
			writer.RenderEndTag ();
			writer.RenderEndTag ();
		}
开发者ID:tgiphil,项目名称:mono,代码行数:10,代码来源:TreeView.cs

示例15: RenderMenuItemSpacing

		void RenderMenuItemSpacing (HtmlTextWriter writer, Unit itemSpacing)
		{
			writer.AddStyleAttribute ("height", itemSpacing.ToString ());
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
			writer.RenderBeginTag (HtmlTextWriterTag.Td);
			writer.RenderEndTag ();
			writer.RenderEndTag ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:TreeView.cs


注:本文中的HtmlTextWriter.AddStyleAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。