本文整理汇总了C#中IHtmlWriter.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlWriter.AddAttribute方法的具体用法?C# IHtmlWriter.AddAttribute怎么用?C# IHtmlWriter.AddAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlWriter
的用法示例。
在下文中一共展示了IHtmlWriter.AddAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAttributesToRender
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
writer.AddAttribute("class", "form-horizontal");
writer.AddAttribute("role", "form");
base.AddAttributesToRender(writer, context);
}
示例2: Render
/// <summary>
/// Renders the resource in the specified <see cref="IHtmlWriter" />.
/// </summary>
public override void Render(IHtmlWriter writer, string friendlyName = null)
{
writer.AddAttribute("href", GetUrl(friendlyName));
writer.AddAttribute("rel", "stylesheet");
writer.AddAttribute("type", "text/css");
writer.RenderSelfClosingTag("link");
}
示例3: Render
/// <summary>
/// Renders the resource in the specified <see cref="IHtmlWriter" />.
/// </summary>
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context)
{
writer.AddAttribute("href", GetUrl());
writer.AddAttribute("rel", "stylesheet");
writer.AddAttribute("type", "text/css");
writer.RenderSelfClosingTag("link");
}
示例4: RenderControl
protected override void RenderControl(IHtmlWriter writer)
{
// begin
if (Mode == TextMode.MultiLine)
{
writer.RenderBeginTag("textarea");
}
else
{
writer.RenderBeginTag("input");
writer.AddAttribute("type", Mode.ToString().ToLower());
}
// content
var expr = KnockoutBindingHelper.GetBindingExpressionOrNull(TextProperty, this);
if (!KnockoutBindingHelper.IsKnockoutBinding(expr))
{
if (Mode == TextMode.MultiLine)
{
writer.WriteText(Text, true);
}
else
{
writer.AddAttribute("value", Text);
}
}
else
{
writer.AddBindingAttribute("value", KnockoutBindingHelper.TranslateToKnockoutProperty(this, TextProperty, expr));
}
// end
writer.RenderEndTag();
}
示例5: Render
/// <summary>
/// Renders the resource in the specified <see cref="IHtmlWriter" />.
/// </summary>
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context)
{
if (CdnUrl != null)
{
writer.AddAttribute("src", CdnUrl);
writer.AddAttribute("type", "text/javascript");
writer.RenderBeginTag("script");
writer.RenderEndTag();
if (Url != null && GlobalObjectName != null)
{
writer.RenderBeginTag("script");
var url = context.TranslateVirtualPath(GetUrl());
writer.WriteUnencodedText(string.Format(CdnFallbackScript, GlobalObjectName, url));
writer.RenderEndTag();
}
}
else if (Url != null)
{
writer.AddAttribute("src", GetUrl());
writer.AddAttribute("type", "text/javascript");
writer.RenderBeginTag("script");
writer.RenderEndTag();
}
}
示例6: RenderControl
protected override void RenderControl(IHtmlWriter writer)
{
var textExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(TextProperty, this);
var needsLabel = KnockoutBindingHelper.IsKnockoutBinding(textExpression) || !string.IsNullOrEmpty(Text);
// render the checkbox
writer.RenderBeginTag("input");
writer.AddAttribute("type", "radio");
var valueExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ValueProperty, this);
if (KnockoutBindingHelper.IsKnockoutBinding(valueExpression))
{
writer.AddBindingAttribute("value", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ValueProperty, valueExpression));
}
else
{
writer.AddAttribute("value", Value);
}
writer.AddAttribute("name", GroupName);
var selectedValueExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(SelectedValueProperty, this);
if (KnockoutBindingHelper.IsKnockoutBinding(selectedValueExpression))
{
writer.AddBindingAttribute("checked", KnockoutBindingHelper.TranslateToKnockoutProperty(this, SelectedValueProperty, selectedValueExpression));
}
else
{
writer.AddAttribute("checked", IsChecked ? "checked" : "");
}
if (needsLabel)
{
EnsureHasID();
writer.AddAttribute("id", ID);
}
writer.RenderEndTag();
// render the label
if (needsLabel)
{
writer.RenderBeginTag("label");
writer.AddAttribute("for", ID);
if (KnockoutBindingHelper.IsKnockoutBinding(textExpression))
{
writer.AddBindingAttribute("", KnockoutBindingHelper.TranslateToKnockoutProperty(this, TextProperty, textExpression));
}
else
{
writer.WriteText(Text, true);
}
writer.RenderEndTag();
}
}
示例7: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
writer.AddAttribute("type", IsSubmitButton ? "submit" : "button");
var clickBinding = GetCommandBinding(ClickProperty);
if (clickBinding != null)
{
writer.AddAttribute("onclick", KnockoutHelper.GenerateClientPostBackScript(clickBinding, context, this));
}
writer.AddKnockoutDataBind("value", this, TextProperty, () => writer.AddAttribute("value", Text));
base.AddAttributesToRender(writer, context);
}
示例8: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
writer.AddAttribute("href", "#");
var clickBinding = GetCommandBinding(ClickProperty);
if (clickBinding != null)
{
writer.AddAttribute("onclick", KnockoutHelper.GenerateClientPostBackScript(clickBinding, context, this));
}
writer.AddKnockoutDataBind("text", this, TextProperty, () => { });
base.AddAttributesToRender(writer, context);
}
示例9: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
if (!RenderOnServer)
{
writer.AddKnockoutDataBind("options", this, DataSourceProperty, () => { });
if (!string.IsNullOrEmpty(DisplayMember))
{
writer.AddKnockoutDataBind("optionsText", KnockoutHelper.MakeStringLiteral(DisplayMember));
}
if (!string.IsNullOrEmpty(ValueMember))
{
writer.AddKnockoutDataBind("optionsValue", KnockoutHelper.MakeStringLiteral(ValueMember));
}
}
// changed event
var selectionChangedBinding = GetCommandBinding(SelectionChangedProperty);
if (selectionChangedBinding != null)
{
writer.AddAttribute("onchange", KnockoutHelper.GenerateClientPostBackScript(selectionChangedBinding, context, this));
}
// selected value
writer.AddKnockoutDataBind("value", this, SelectedValueProperty, () => { });
base.AddAttributesToRender(writer, context);
}
示例10: RenderContents
/// <summary>
/// Renders the contents inside the control begin and end tags.
/// </summary>
protected override void RenderContents(IHtmlWriter writer, RenderContext context)
{
if (RenderOnServer)
{
// render items
bool first = true;
foreach (var item in GetIEnumerableFromDataSource(DataSource))
{
var value = string.IsNullOrEmpty(ValueMember) ? item : ReflectionUtils.GetObjectProperty(item, ValueMember);
var text = string.IsNullOrEmpty(DisplayMember) ? item : ReflectionUtils.GetObjectProperty(item, DisplayMember);
if (first)
{
writer.WriteUnencodedText(Environment.NewLine);
first = false;
}
writer.WriteUnencodedText(" "); //Indent
writer.AddAttribute("value", value != null ? value.ToString() : "");
writer.RenderBeginTag("option");
writer.WriteText(text != null ? text.ToString() : "");
writer.RenderEndTag();
writer.WriteUnencodedText(Environment.NewLine);
}
}
}
示例11: Render
/// <summary>
/// Renders the resource in the specified <see cref="IHtmlWriter" />.
/// </summary>
public override void Render(IHtmlWriter writer, string friendlyName = null)
{
writer.AddAttribute("type", "text/javascript");
writer.RenderBeginTag("script");
writer.WriteUnencodedText(Code);
writer.RenderEndTag();
}
示例12: RenderInputTag
/// <summary>
/// Renders the input tag.
/// </summary>
protected override void RenderInputTag(IHtmlWriter writer)
{
var checkedBinding = GetValueBinding(CheckedProperty);
var checkedItemsBinding = GetValueBinding(CheckedItemsProperty);
if (checkedBinding != null && checkedItemsBinding == null)
{
// boolean mode
writer.AddKnockoutDataBind("checked", this, CheckedProperty, () => { });
writer.AddKnockoutDataBind("checkedValue", "true");
}
else if (checkedBinding == null && checkedItemsBinding != null)
{
// collection mode
writer.AddKnockoutDataBind("checked", this, CheckedItemsProperty, () => { });
writer.AddKnockoutDataBind("checkedValue", this, CheckedValueProperty, () =>
{
var checkedValue = (CheckedValue ?? string.Empty).ToString();
if (!string.IsNullOrEmpty(checkedValue))
{
writer.AddKnockoutDataBind("checkedValue", KnockoutHelper.MakeStringLiteral(checkedValue));
}
});
}
else
{
throw new Exception("Either the Checked or the CheckedItems property of a CheckBox must be set.");
}
// render the input tag
writer.AddAttribute("type", "checkbox");
writer.RenderSelfClosingTag("input");
}
示例13: AddAttributesToRender
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
writer.AddAttribute("id", ID);
writer.AddAttribute("name", Constants.SpaContentPlaceHolderID);
writer.AddAttribute(Constants.SpaContentPlaceHolderDataAttributeName, GetSpaContentPlaceHolderUniqueId());
if (!string.IsNullOrEmpty(DefaultRouteName))
{
var route = context.RequestContext.Configuration.RouteTable[DefaultRouteName];
if (route.ParameterNames.Any())
{
throw new ArgumentException(string.Format("The route {0} specified in SpaContentPlaceHolder DefaultRouteName property cannot contain route parameters!", DefaultRouteName));
}
writer.AddAttribute(Constants.SpaContentPlaceHolderDefaultRouteDataAttributeName, route.Url);
}
base.AddAttributesToRender(writer, context);
}
示例14: AddEventAttributeToRender
private void AddEventAttributeToRender(IHtmlWriter writer, RenderContext context, string name, RedwoodProperty property)
{
var binding = GetCommandBinding(property);
if (binding != null)
{
writer.AddAttribute(name, KnockoutHelper.GenerateClientPostBackScript(binding, context, this));
}
}
示例15: Render
/// <summary>
/// Renders the resource in the specified <see cref="IHtmlWriter" />.
/// </summary>
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context)
{
if (string.IsNullOrWhiteSpace(Code)) return;
writer.AddAttribute("type", "text/javascript");
writer.RenderBeginTag("script");
writer.WriteUnencodedText(Code);
writer.RenderEndTag();
}