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


C# HtmlTextWriter.AddAttribute方法代码示例

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


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

示例1: Render

 protected internal override void Render(HtmlTextWriter writer) {
     // Render as a label in designer for accessibility
     if (RenderAsLabel) {
         // Total hack for accessibility of labels for login controls!
         writer.Write("<asp:label runat=\"server\" AssociatedControlID=\"");
         writer.Write(_for.ID);
         writer.Write("\" ID=\"");
         writer.Write(_for.ID);
         writer.Write("Label\">");
         writer.Write(Text);
         writer.Write("</asp:label>");
     }
     else {
         writer.AddAttribute(HtmlTextWriterAttribute.For, _for.ClientID);
         writer.RenderBeginTag(HtmlTextWriterTag.Label);
         base.Render(writer);
         writer.RenderEndTag();
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:19,代码来源:LabelLiteral.cs

示例2: RenderChildren

		protected internal override void RenderChildren (HtmlTextWriter writer)
		{
			base.RenderChildren (writer);
			if (title == null) {
				writer.RenderBeginTag (HtmlTextWriterTag.Title);
				if (!String.IsNullOrEmpty (titleText))
					writer.Write (titleText);
				writer.RenderEndTag ();
			}
#if NET_4_0
			if (descriptionMeta == null && descriptionText != null) {
				writer.AddAttribute ("name", "description");
				writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (descriptionText));
				writer.RenderBeginTag (HtmlTextWriterTag.Meta);
				writer.RenderEndTag ();
			}

			if (keywordsMeta == null && keywordsText != null) {
				writer.AddAttribute ("name", "keywords");
				writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (keywordsText));
				writer.RenderBeginTag (HtmlTextWriterTag.Meta);
				writer.RenderEndTag ();
			}
#endif
			if (styleSheet != null)
				styleSheet.Render (writer);
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:HtmlHead.cs

示例3: 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

示例4: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			Page page = Page;
			if (page != null)
				page.VerifyRenderingInServerForm (this);

			base.AddAttributesToRender (w);
			bool enabled = IsEnabled;
			string onclick = OnClientClick;
			onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
			if (HasAttributes && Attributes ["onclick"] != null) {
				onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]);
				Attributes.Remove ("onclick");
			}

			if (onclick.Length > 0)
				w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
			
			if (enabled && page != null) {
				PostBackOptions options = GetPostBackOptions ();
				string href = page.ClientScript.GetPostBackEventReference (options, true);
				w.AddAttribute (HtmlTextWriterAttribute.Href, href);
			}
			
			AddDisplayStyleAttribute (w);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:26,代码来源:LinkButton.cs

示例5: AddAttributesToRender

		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			base.AddAttributesToRender(writer);
			if(RenderUplevel)
			{
				writer.AddAttribute("evaluationfunction", "RequiredFieldValidatorEvaluateIsValid");
				writer.AddAttribute("initialvalue", InitialValue);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:RequiredFieldValidator.cs

示例6: RenderHidden

 /// <summary>
 /// Renders the hidden.
 /// </summary>
 /// <param name="w">The w.</param>
 protected void RenderHidden(HtmlTextWriter w)
 {
     w.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
     w.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
     w.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
     w.AddAttribute(HtmlTextWriterAttribute.Value, Text);
     w.RenderBeginTag(HtmlTextWriterTag.Input);
     w.RenderEndTag();
 }
开发者ID:BclEx,项目名称:BclEx-Web,代码行数:13,代码来源:CheckBoxEx.cs

示例7: GetDesignTimeHtml

                /// <summary>
                /// The design time generated HTML for the control.
                /// </summary>
                /// <returns>A string containing the HTML rendering.</returns>
                public override string GetDesignTimeHtml()
                {
                    // Extremely simple design time rendering!
                    // will work on something better sooner or later.
                    // This acts as a placeholder.
                    Web.PlotSurface2D plot = (Web.PlotSurface2D)Component;

                    int xs = Convert.ToInt32(plot.Width.Value);
                    if ( xs < 1 ) return "";
                    int ys = Convert.ToInt32(plot.Height.Value);
                    if ( ys < 1 ) return "";

                    StringWriter sw = new StringWriter();
                    HtmlTextWriter output= new HtmlTextWriter(sw);
                    output.AddAttribute("border",plot.BorderWidth.ToString());
                    output.AddAttribute("borderColor",plot.BorderColor.ToKnownColor().ToString());
                    output.AddAttribute("cellSpacing","0");
                    output.AddAttribute("cellPadding","0");
                    output.AddAttribute("width",xs.ToString());
                    output.RenderBeginTag("table ");
                    output.RenderBeginTag("tr");
                    output.AddAttribute("vAlign","center");
                    output.AddAttribute("align","middle");
                    output.AddAttribute("height",ys.ToString());
                    output.RenderBeginTag("td");
                    output.RenderBeginTag("P");
                    output.Write("PlotSurface2D:" + plot.Title);
                    output.RenderEndTag();
                    output.RenderEndTag();
                    output.RenderEndTag();
                    output.RenderEndTag();
                    output.Flush();
                    return sw.ToString();
                }
开发者ID:Amichai,项目名称:ComputationalPhysics,代码行数:38,代码来源:Web.Design.PlotSurface2D.cs

示例8: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			if (RenderUplevel) {
#if NET_2_0
				RegisterExpandoAttribute (ClientID, "evaluationfunction", "RequiredFieldValidatorEvaluateIsValid");
				RegisterExpandoAttribute (ClientID, "initialvalue", InitialValue, true);
#else
				w.AddAttribute ("evaluationfunction", "RequiredFieldValidatorEvaluateIsValid", false);
				w.AddAttribute ("initialvalue", InitialValue);
#endif
			}

			base.AddAttributesToRender (w);
		}
开发者ID:nobled,项目名称:mono,代码行数:14,代码来源:RequiredFieldValidator.cs

示例9: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			base.AddAttributesToRender (w);
			AddDisplayStyleAttribute (w);
			if (!IsEnabled)
				return;
			// add attributes - only if they're not empty
			string t = Target;
			string s = NavigateUrl;
			if (s.Length > 0)
				w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s));
			if (t.Length > 0)
				w.AddAttribute (HtmlTextWriterAttribute.Target, t);
		}
开发者ID:vargaz,项目名称:mono,代码行数:14,代码来源:HyperLink.cs

示例10: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter writer) {

			ControlStyle.CopyFrom (_container.ControlStyle);
			writer.AddAttribute (HtmlTextWriterAttribute.Id, _container.ClientID);

			base.AddAttributesToRender (writer);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:ContainedTable.cs

示例11: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			if (RenderUplevel) {
#if NET_2_0
				RegisterExpandoAttribute (ClientID, "evaluationfunction", "RegularExpressionValidatorEvaluateIsValid");
				if (ValidationExpression.Length > 0)
					RegisterExpandoAttribute (ClientID, "validationexpression", ValidationExpression, true);
#else
				w.AddAttribute ("evaluationfunction", "RegularExpressionValidatorEvaluateIsValid", false);
				if (ValidationExpression != "")
					w.AddAttribute ("validationexpression", ValidationExpression);
#endif
			}

			base.AddAttributesToRender (w);
		}
开发者ID:nobled,项目名称:mono,代码行数:16,代码来源:RegularExpressionValidator.cs

示例12: Render

    protected override void Render(HtmlTextWriter writer)
    {
        //Ugly hack time..
        //Placeholder will be the parent control when the user is in wysiwyg mode
        //We don't want to close any divs if we're being rendered within the umbraco content editor.
        if (!(Parent.TemplateSourceDirectory.EndsWith("umbraco")) && EscapeUserContentBlock)
        {
            writer.WriteLine("</div>");
        }

        //Render in Macro div
        if (RenderInMacroDiv) {
            //Declare this a macro tag
            writer.AddAttribute("class", "macro");
            writer.RenderBeginTag("div");
        }

        base.Render(writer);

        if (RenderInMacroDiv) {
            writer.RenderEndTag();
        }

        if (!(Parent.TemplateSourceDirectory.EndsWith("umbraco")) && EscapeUserContentBlock)
        {
            //Re-open the macro
            writer.WriteLine("<div class='user-content'>");
        }
    }
开发者ID:kensykora,项目名称:Umbraco-Presentation,代码行数:29,代码来源:BaseWidget.cs

示例13: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			if (RenderUplevel) {
#if NET_2_0
				if (Page!=null){
					RegisterExpandoAttribute (ClientID, "type", Type.ToString ());

					switch (Type) {
					case ValidationDataType.Date:
						DateTimeFormatInfo dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
						string pattern = dateTimeFormat.ShortDatePattern;
						string dateorder = (pattern.StartsWith ("y", true, Helpers.InvariantCulture) ? "ymd" : (pattern.StartsWith ("m", true, Helpers.InvariantCulture) ? "mdy" : "dmy"));
						RegisterExpandoAttribute (ClientID, "dateorder", dateorder);
						RegisterExpandoAttribute (ClientID, "cutoffyear", dateTimeFormat.Calendar.TwoDigitYearMax.ToString ());
						break;
					case ValidationDataType.Currency:
						NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
						RegisterExpandoAttribute (ClientID, "decimalchar", numberFormat.CurrencyDecimalSeparator, true);
						RegisterExpandoAttribute (ClientID, "groupchar", numberFormat.CurrencyGroupSeparator, true);
						RegisterExpandoAttribute (ClientID, "digits", numberFormat.CurrencyDecimalDigits.ToString());
						RegisterExpandoAttribute (ClientID, "groupsize", numberFormat.CurrencyGroupSizes [0].ToString ());
						break;
					}
				}
#else
				w.AddAttribute ("datatype", Type.ToString());
#endif
			}

			base.AddAttributesToRender (w);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:31,代码来源:BaseCompareValidator.cs

示例14: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			base.AddAttributesToRender (w);
			AddDisplayStyleAttribute (w);
			if (!IsEnabled)
				return;
			// add attributes - only if they're not empty
			string t = Target;
			string s = NavigateUrl;
			if (s.Length > 0)
#if TARGET_J2EE
				w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s, String.Compare (t, "_blank", StringComparison.InvariantCultureIgnoreCase) != 0));
#else
				w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s));
#endif
			if (t.Length > 0)
				w.AddAttribute (HtmlTextWriterAttribute.Target, t);
		}
开发者ID:nobled,项目名称:mono,代码行数:18,代码来源:HyperLink.cs

示例15: AddAttributesToRender

        /// <devdoc>
        /// <para>Adds header cell attributes to the list of attributes to render.</para>
        /// </devdoc>
        protected override void AddAttributesToRender(HtmlTextWriter writer) {
            base.AddAttributesToRender(writer);

            TableHeaderScope scope = Scope;
            if (scope != TableHeaderScope.NotSet) {
                if (scope == TableHeaderScope.Column) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                }
                else {
                    writer.AddAttribute(HtmlTextWriterAttribute.Scope, "row");
                }
            }

            String abbr = AbbreviatedText;
            if (!String.IsNullOrEmpty(abbr)) {
                writer.AddAttribute(HtmlTextWriterAttribute.Abbr, abbr);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:21,代码来源:DataControlFieldHeaderCell.cs


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