• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IHtmlWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


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


示例18: AddAttributesToRender

        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            AddEventAttributeToRender(writer, context, "onclick", ClickProperty);

            AddEventAttributeToRender(writer, context, "onchange", ValueChangedProperty);

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


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


示例20: RenderControl

        /// <summary>
        /// Renders the specified writer.
        /// </summary>
        protected override void RenderControl(IHtmlWriter writer)
        {
            writer.RenderBeginTag("table");

            if (ItemTemplate != null)
            {
                var itemsSourceExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ItemsSourceProperty, this);
                if (KnockoutBindingHelper.IsKnockoutBinding(itemsSourceExpression))
                {
                    // knockout template
                    writer.RenderBeginTag("tbody");
                    writer.AddBindingAttribute("foreach", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ItemsSourceProperty, itemsSourceExpression));

                    if (string.IsNullOrEmpty(KeyPropertyName))
                    {
                        ItemTemplate.DataContext = CreateClientTemplateInstanceDataContextBinding();
                    }
                    else
                    {
                        ItemTemplate.DataContext = CreateClientTemplateInstanceDataContextBinding(KeyPropertyName);
                    }
                    ItemTemplate.Render(writer);

                    writer.RenderEndTag();
                }
                else if (ItemsSource != null)
                {
                    writer.RenderBeginTag("tbody");
                    var index = 0;

                    var rawItemsSourceValue = this.GetRawValue(ItemsSourceProperty);

                    foreach (var item in ItemsSource)
                    {
                        // render on server side
                        writer.RenderBeginTag("tr");

                        if (string.IsNullOrEmpty(KeyPropertyName) || item == null)
                        {
                            ItemTemplate.DataContext = CreateServerTemplateInstanceDataContextBinding(index);
                        }
                        else
                        {
                            var keyValue = GetKeyValue(item);
                            ItemTemplate.DataContext = CreateServerTemplateInstanceDataContextBinding(KeyPropertyName, keyValue);
                        }
                        ItemTemplate.Render(writer);

                        writer.RenderEndTag();

                        index++;
                    }
                    writer.RenderEndTag();
                }
            }

            writer.RenderEndTag();
        }
开发者ID:jechtom,项目名称:Redwood,代码行数:61,代码来源:Table.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IHttpClient类代码示例发布时间:2022-05-24
下一篇:
C# IHtmlString类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap