本文整理汇总了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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例5: AddAttributesToRender
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
if(RenderUplevel)
{
writer.AddAttribute("evaluationfunction", "RequiredFieldValidatorEvaluateIsValid");
writer.AddAttribute("initialvalue", InitialValue);
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例10: AddAttributesToRender
protected override void AddAttributesToRender (HtmlTextWriter writer) {
ControlStyle.CopyFrom (_container.ControlStyle);
writer.AddAttribute (HtmlTextWriterAttribute.Id, _container.ClientID);
base.AddAttributesToRender (writer);
}
示例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);
}
示例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'>");
}
}
示例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);
}
示例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);
}
示例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);
}
}