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


C# IHtmlWriter.AddKnockoutDataBind方法代码示例

本文整理汇总了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");
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:36,代码来源:CheckBox.cs

示例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);
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:31,代码来源:SelectHtmlControlBase.cs

示例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));
         }
     });
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:11,代码来源:RadioButton.cs

示例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) + "]; }");
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:12,代码来源:SelectHtmlControlHelpers.cs

示例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));
         }
     });
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:15,代码来源:CheckBox.cs

示例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();
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:10,代码来源:ValidationSummary.cs

示例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);
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:8,代码来源:RouteLink.cs

示例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);
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:9,代码来源:RadioButton.cs

示例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);
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:13,代码来源:ValidationSummary.cs

示例10: RenderEnabledProperty

 public static void RenderEnabledProperty(IHtmlWriter writer, SelectorBase selector)
 {
     writer.AddKnockoutDataBind("enable", selector, SelectorBase.EnabledProperty, () =>
     {
         if (!selector.Enabled)
         {
             writer.AddAttribute("disabled", "disabled");
         }
     });
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:10,代码来源:SelectHtmlControlHelpers.cs

示例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);
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:13,代码来源:ValidationSummary.cs

示例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));
     }
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:11,代码来源:RouteLinkHelpers.cs

示例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);
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:12,代码来源:ComboBox.cs

示例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);
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:15,代码来源:ButtonBase.cs

示例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);
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:16,代码来源:ValidationMessage.cs


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