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


C# IHtmlWriter.AddAttribute方法代码示例

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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