本文整理汇总了C#中IHtmlWriter.AddKnockoutDataBind方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlWriter.AddKnockoutDataBind方法的具体用法?C# IHtmlWriter.AddKnockoutDataBind怎么用?C# IHtmlWriter.AddKnockoutDataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlWriter
的用法示例。
在下文中一共展示了IHtmlWriter.AddKnockoutDataBind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: 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);
}
示例3: RenderCheckedValueAttribute
protected virtual void RenderCheckedValueAttribute(IHtmlWriter writer)
{
writer.AddKnockoutDataBind("checkedValue", this, CheckedValueProperty, () =>
{
var checkedValue = (CheckedValue ?? string.Empty).ToString();
if (!string.IsNullOrEmpty(checkedValue))
{
writer.AddKnockoutDataBind("checkedValue", KnockoutHelper.MakeStringLiteral(checkedValue));
}
});
}
示例4: RenderOptionsProperties
public static void RenderOptionsProperties(IHtmlWriter writer, SelectorBase selector)
{
writer.AddKnockoutDataBind("options", selector, ItemsControl.DataSourceProperty, renderEvenInServerRenderingMode: true);
if (!String.IsNullOrEmpty(selector.DisplayMember))
{
writer.AddKnockoutDataBind("optionsText", "function (i) { return ko.unwrap(i)[" + KnockoutHelper.MakeStringLiteral(selector.DisplayMember) + "]; }");
}
if (!String.IsNullOrEmpty(selector.ValueMember))
{
writer.AddKnockoutDataBind("optionsValue", "function (i) { return ko.unwrap(i)[" + KnockoutHelper.MakeStringLiteral(selector.ValueMember) + "]; }");
}
}
示例5: RenderCheckedItemsProperty
protected virtual void RenderCheckedItemsProperty(IHtmlWriter writer)
{
RenderCheckedItemsBinding(writer);
writer.AddKnockoutDataBind("checkedArrayContainsObservables", "true");
writer.AddKnockoutDataBind("dotvvm-checkbox-updateAfterPostback", "true");
RenderDotvvmCheckedPointerBinding(writer);
writer.AddKnockoutDataBind("checkedValue", this, CheckedValueProperty, () =>
{
var checkedValue = (CheckedValue ?? string.Empty).ToString();
if (!string.IsNullOrEmpty(checkedValue))
{
writer.AddKnockoutDataBind("checkedValue", KnockoutHelper.MakeStringLiteral(checkedValue));
}
});
}
示例6: RenderContents
/// <summary>
/// Renders the contents inside the control begin and end tags.
/// </summary>
protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
{
// render template
writer.AddKnockoutDataBind("text", "errorMessage");
writer.RenderBeginTag("li");
writer.RenderEndTag();
}
示例7: AddAttributesToRender
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
RouteLinkHelpers.WriteRouteLinkHrefAttribute(RouteName, this, writer, context);
writer.AddKnockoutDataBind("text", this, TextProperty, () => { });
base.AddAttributesToRender(writer, context);
}
示例8: RenderGroupNameAttribute
protected virtual void RenderGroupNameAttribute(IHtmlWriter writer)
{
var group = new KnockoutBindingGroup();
group.Add("name", this, GroupNameProperty, () =>
{
writer.AddAttribute("name", GroupName);
});
writer.AddKnockoutDataBind("attr", group);
}
示例9: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
{
var expression = KnockoutHelper.GetValidationTargetExpression(this);
if (expression != null)
{
writer.AddKnockoutDataBind("foreach", "dotvvm.validation.getValidationErrors(" + expression + ", " + IncludeErrorsFromChildren.ToString().ToLower() + ")");
}
base.AddAttributesToRender(writer, context);
}
示例10: RenderEnabledProperty
public static void RenderEnabledProperty(IHtmlWriter writer, SelectorBase selector)
{
writer.AddKnockoutDataBind("enable", selector, SelectorBase.EnabledProperty, () =>
{
if (!selector.Enabled)
{
writer.AddAttribute("disabled", "disabled");
}
});
}
示例11: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
var expression = KnockoutHelper.GetValidationTargetExpression(this, true);
if (expression != null)
{
writer.AddKnockoutDataBind("foreach", expression + ".$validationErrors");
}
base.AddAttributesToRender(writer, context);
}
示例12: WriteRouteLinkHrefAttribute
public static void WriteRouteLinkHrefAttribute(string routeName, HtmlGenericControl control, IHtmlWriter writer, RenderContext context)
{
if (!control.RenderOnServer)
{
writer.AddKnockoutDataBind("attr", "{ href: " + GenerateKnockoutHrefExpression(routeName, control, context) + "}");
}
else
{
writer.AddAttribute("href", EvaluateRouteUrl(routeName, control, context));
}
}
示例13: AddAttributesToRender
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
if (!RenderOnServer)
{
if (!string.IsNullOrWhiteSpace(EmptyItemText))
{
writer.AddKnockoutDataBind("optionsCaption", KnockoutHelper.MakeStringLiteral(EmptyItemText));
}
}
base.AddAttributesToRender(writer, context);
}
示例14: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
{
writer.AddKnockoutDataBind("dotvvmEnable", this, EnabledProperty, () =>
{
if (!Enabled)
{
writer.AddAttribute("disabled", "disabled");
}
});
base.AddAttributesToRender(writer, context);
}
示例15: AddAttributesToRender
/// <summary>
/// Adds all attributes that should be added to the control begin tag.
/// </summary>
protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
{
var validatedValueBinding = GetValueBinding(ValidatedValueProperty);
if (validatedValueBinding != null)
{
writer.AddKnockoutDataBind("dotvvmValidation", this, ValidatedValueProperty, () => { });
var options = string.Format("{{'mode':'{0}', 'cssClass':{1}}}", KnockoutHelper.ConvertToCamelCase(Mode.ToString()), KnockoutHelper.MakeStringLiteral(InvalidCssClass));
writer.AddKnockoutDataBind("dotvvmValidationOptions", options);
}
base.AddAttributesToRender(writer, context);
}