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


C# IHtmlWriter类代码示例

本文整理汇总了C#中IHtmlWriter的典型用法代码示例。如果您正苦于以下问题:C# IHtmlWriter类的具体用法?C# IHtmlWriter怎么用?C# IHtmlWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SetupDataBind

 private void SetupDataBind(IHtmlWriter htmlWriter)
 {
     htmlWriter
         .Prop("id", this.propertyName)
         .Prop("name", this.propertyName)
         .Prop("data-bind", "value:" + this.field.PropertyName);
 }
开发者ID:mehmetgoren,项目名称:AppX.UI,代码行数:7,代码来源:InputWriters.cs

示例2: RenderControl

 protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (!RenderOnServer || GetIEnumerableFromDataSource(DataSource)?.GetEnumerator()?.MoveNext() != true)
     {
         base.RenderControl(writer, context);
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:7,代码来源:EmptyData.cs

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

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

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

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

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

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

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

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

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

示例12: AddAttributesToRender

        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            writer.AddAttribute("class", "form-horizontal");
            writer.AddAttribute("role", "form");

            base.AddAttributesToRender(writer, context);
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:7,代码来源:HorizontalForm.cs

示例13: AddAttributesToRender

        /// <summary>
        /// Adds all attributes that should be added to the control begin tag.
        /// </summary>
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            object id;
            if (!IsPropertySet(ClientIDProperty))
            {
                SetValueRaw(ClientIDProperty, id = CreateClientId());
            }
            else
            {
                id = GetValueRaw(ClientIDProperty);
            }
            if (id != null) Attributes["id"] = id;

            CheckInnerTextUsage();

            // verify that the properties are used only where they should
            if (!RendersHtmlTag)
            {
                EnsureNoAttributesSet();
            }
            else
            {
                var attrBindingGroup = new KnockoutBindingGroup();
                // render hard-coded HTML attributes
                foreach (var attribute in Attributes)
                {
                    if (attribute.Value is IValueBinding)
                    {
                        var binding = attribute.Value as IValueBinding;
                        attrBindingGroup.Add(attribute.Key, binding.GetKnockoutBindingExpression());
                        if (!RenderOnServer)
                            continue;
                    }
                    AddHtmlAttribute(writer, attribute.Key, attribute.Value);
                }

                if (!attrBindingGroup.IsEmpty)
                {
                    writer.AddKnockoutDataBind("attr", attrBindingGroup);
                }

                // handle Visible property
                AddVisibleAttributeOrBinding(writer);

                // handle Text property
                writer.AddKnockoutDataBind("text", this, InnerTextProperty, () =>
                {
                    // inner Text is rendered as attribute only if contains binding
                    // otherwise it is rendered directly as encoded content
                    if (!string.IsNullOrWhiteSpace(InnerText))
                    {
                        Children.Clear();
                        Children.Add(new Literal(InnerText));
                    }
                });
            }

            base.AddAttributesToRender(writer, context);
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:62,代码来源:HtmlGenericControl.cs

示例14: RenderControl

 protected override void RenderControl(IHtmlWriter writer)
 {
     writer.RenderBeginTag(Element);
     if (htmlAttributesStorage != null)
         htmlAttributesStorage.Render(writer);
     base.RenderControl(writer);
     writer.RenderEndTag(true);
 }
开发者ID:jechtom,项目名称:Redwood,代码行数:8,代码来源:HtmlElement.cs

示例15: RenderChangedEvent

 public static void RenderChangedEvent(IHtmlWriter writer, SelectorBase selector)
 {
     var selectionChangedBinding = selector.GetCommandBinding(SelectorBase.SelectionChangedProperty);
     if (selectionChangedBinding != null)
     {
         writer.AddAttribute("onchange", KnockoutHelper.GenerateClientPostBackScript(nameof(SelectorBase.SelectionChanged), selectionChangedBinding, selector, isOnChange: true, useWindowSetTimeout: true));
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:8,代码来源:SelectHtmlControlHelpers.cs


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