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


C# IHtmlWriter.WriteText方法代码示例

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


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

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

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

示例3: RenderControl

        protected override void RenderControl(IHtmlWriter writer)
        {
            if (InternalScriptUrls != null)
            {
                foreach (var script in InternalScriptUrls)
                {
                    writer.RenderBeginTag("script");
                    writer.AddAttribute("type", "text/javascript");
                    writer.AddAttribute("src", script);
                    writer.RenderEndTag(true);
                }
            }

            writer.RenderBeginTag("script");
            writer.AddAttribute("type", "text/javascript");
            writer.WriteText("(function () { var viewModelData = ", false);
            writer.WriteText(SerializedViewModel, false);
            writer.WriteText(";var vm = Redwood.CreateViewModel(viewModelData, new " + ViewModelClientName + "());ko.applyBindings(vm);Redwood.ViewModels['Default'] = vm;})();", false);
            writer.RenderEndTag();
        }
开发者ID:jechtom,项目名称:Redwood,代码行数:20,代码来源:IntegrationScripts.cs

示例4: RenderContents

 /// <summary>
 /// Renders the contents inside the control begin and end tags.
 /// </summary>
 protected override void RenderContents(IHtmlWriter writer, RenderContext context)
 {
     var textBinding = GetBinding(TextProperty);
     if (textBinding == null && !string.IsNullOrEmpty(Text))
     {
         // render static value of the text property
         writer.WriteText(Text);
     }
     else
     {
         // render control contents
         RenderChildren(writer, context);
     }
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:17,代码来源:LinkButton.cs

示例5: RenderContents

        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            if (RenderOnServer)
            {
                if (!string.IsNullOrWhiteSpace(EmptyItemText))
                {
                    writer.RenderBeginTag("option");
                    writer.WriteText(EmptyItemText);
                    writer.RenderEndTag();
                }
            }

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

示例6: RenderContents

 protected override void RenderContents(IHtmlWriter writer, RenderContext context)
 {
     var textBinding = GetBinding(TextProperty);
     if (textBinding?.Javascript == null)
     {
         if (!string.IsNullOrEmpty(Text))
         {
             writer.WriteText(Text);
         }
         else
         {
             base.RenderContents(writer, context);
         }
     }
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:15,代码来源:RouteLink.cs

示例7: RenderContents

 /// <summary>
 /// Renders the contents inside the control begin and end tags.
 /// </summary>
 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (!HasValueBinding(TextProperty) || RenderOnServer)
     {
         if (!string.IsNullOrEmpty(Text))
         {
             // render static value of the text property
             writer.WriteText(Text);
         }
         else
         {
             // render control contents
             RenderChildren(writer, context);
         }
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:19,代码来源:LinkButton.cs

示例8: RenderLabel

 private void RenderLabel(IHtmlWriter writer)
 {
     writer.AddAttribute("class", "control-label col-sm-2");
     var textBinding = GetBinding(LabelTextProperty);
     if (textBinding != null)
     {
         writer.AddKnockoutDataBind("text", this, LabelTextProperty, () => { });
         writer.RenderBeginTag("label");
         writer.RenderEndTag();
     }
     else
     {
         writer.RenderBeginTag("label");
         writer.WriteText(LabelText);
         writer.RenderEndTag();
     }
 }
开发者ID:adamjez,项目名称:dotvvm,代码行数:17,代码来源:FormGroup.cs

示例9: 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", "checkbox");
            var isCheckedExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(IsCheckedProperty, this);
            if (KnockoutBindingHelper.IsKnockoutBinding(isCheckedExpression))
            {
                writer.AddBindingAttribute("checked", KnockoutBindingHelper.TranslateToKnockoutProperty(this, IsCheckedProperty, isCheckedExpression));
            }
            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,代码行数:40,代码来源:CheckBox.cs

示例10: RenderControl

        /// <summary>
        /// Renders the control to the writer.
        /// </summary>
        protected override void RenderControl(IHtmlWriter writer)
        {
            writer.RenderBeginTag("select");

            var itemsSourceExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ItemsSourceProperty, this);
            if (KnockoutBindingHelper.IsKnockoutBinding(itemsSourceExpression))
            {
                // render items on client
                writer.AddBindingAttribute("options", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ItemsSourceProperty, itemsSourceExpression));
                if (DisplayNullItem)
                {
                    writer.AddBindingAttribute("optionsCaption", NullItemText);
                }
                if (DisplayMemberBinding != null)
                {
                    writer.AddBindingAttribute("optionsText", KnockoutBindingHelper.TranslateToKnockoutProperty(this, DisplayMemberBindingProperty, DisplayMemberBinding));
                }
                if (ValueMemberBinding != null)
                {
                    writer.AddBindingAttribute("optionsValue", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ValueMemberBindingProperty, ValueMemberBinding));
                }
            }
            else if (ItemsSource != null)
            {
                // render items on server
                if (DisplayNullItem)
                {
                    writer.RenderBeginTag("option");
                    writer.AddAttribute("value", "");
                    writer.WriteText(NullItemText, true);
                    writer.RenderEndTag();
                }

                // render on server
                foreach (var item in ItemsSource)
                {
                    var itemValue = EvaluateValueMember(item);
                    var itemText = (EvaluateDisplayMember(item) ?? "").ToString();
                    var isSelected = (itemValue == null && SelectedValue == null) || itemValue.Equals(SelectedValue);

                    writer.RenderBeginTag("option");
                    writer.AddAttribute("value", (itemValue ?? "").ToString());
                    writer.WriteText(itemText, true);
                    if (isSelected)
                    {
                        writer.AddAttribute("selected", "selected");
                    }
                    writer.RenderEndTag();
                }
            }
        }
开发者ID:jechtom,项目名称:Redwood,代码行数:54,代码来源:DropDownList.cs

示例11: RenderContents

 /// <summary>
 /// Renders the contents inside the control begin and end tags.
 /// </summary>
 protected override void RenderContents(IHtmlWriter writer, RenderContext context)
 {
     if (Type == TextBoxType.MultiLine && GetValueBinding(TextProperty) == null)
     {
         writer.WriteText(Text);
     }
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:10,代码来源:TextBox.cs

示例12: RenderContents

        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!renderAsKnockoutBinding)
            {
                var textToDisplay = "";
                if (isFormattingRequired)
                {
                    var formatString = FormatString;
                    if (string.IsNullOrEmpty(formatString))
                    {
                        formatString = "G";
                    }
                    textToDisplay = string.Format("{0:" + formatString + "}", GetValue(TextProperty));
                }
                else
                {
                    textToDisplay = GetValue(TextProperty)?.ToString() ?? "";
                }

                writer.WriteText(textToDisplay);
            }
        }
开发者ID:darilek,项目名称:dotvvm,代码行数:22,代码来源:Literal.cs

示例13: RenderControl

        /// <summary>
        /// Renders the control into the specified writer.
        /// </summary>
        protected override void RenderControl(IHtmlWriter writer, RenderContext context)
        {
            var textBinding = GetBinding(TextProperty);
            if (textBinding != null && !RenderOnServer)
            {
                var expression = textBinding.TranslateToClientScript(this, TextProperty);
                if (!string.IsNullOrEmpty(FormatString))
                {
                    expression = "redwood.formatString(" + JsonConvert.SerializeObject(FormatString) + ", " + expression + ")";
                }

                writer.AddKnockoutDataBind(HtmlEncode ? "text" : "html", expression);
                writer.RenderBeginTag("span");
                writer.RenderEndTag();
            }
            else
            {
                var textToDisplay = Text;
                if (!string.IsNullOrEmpty(FormatString))
                {
                    textToDisplay = string.Format("{0:" + FormatString + "}", textToDisplay);
                }

                if (HtmlEncode)
                {
                    writer.WriteText(textToDisplay);
                }
                else
                {
                    writer.WriteUnencodedText(textToDisplay);
                }
            }
        }
开发者ID:adamjez,项目名称:dotvvm,代码行数:36,代码来源:Literal.cs

示例14: RenderControl

        /// <summary>
        /// Renders the control into the specified writer.
        /// </summary>
        protected override void RenderControl(IHtmlWriter writer, RenderContext context)
        {
            var textBinding = GetBinding(TextProperty);
            if (textBinding != null && !RenderOnServer && textBinding.Javascript != null)
            {
                var expression = textBinding.Javascript;
                if (!string.IsNullOrEmpty(FormatString))
                {
                    expression = "dotvvm.formatString(" + JsonConvert.SerializeObject(FormatString) + ", " + expression + ")";
                }

                writer.AddKnockoutDataBind(HtmlEncode ? "text" : "html", expression);
                AddAttributesToRender(writer, context);
                writer.RenderBeginTag("span");
                writer.RenderEndTag();
            }
            else
            {
                if (AlwaysRenderSpan)
                {
                    AddAttributesToRender(writer, context);
                    writer.RenderBeginTag("span");
                }

                var textToDisplay = "";
                if (!string.IsNullOrEmpty(FormatString))
                {
                    textToDisplay = string.Format("{0:" + FormatString + "}", GetValue(TextProperty));
                }
                else
                {
                    textToDisplay = GetValue(TextProperty)?.ToString() ?? "";
                }

                if (HtmlEncode)
                {
                    writer.WriteText(textToDisplay);
                }
                else
                {
                    writer.WriteUnencodedText(textToDisplay);
                }

                if (AlwaysRenderSpan)
                {
                    writer.RenderEndTag();
                }
            }
        }
开发者ID:holajan,项目名称:dotvvm,代码行数:52,代码来源:Literal.cs

示例15: RenderContents

 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (shouldRenderText)
     {
         if (!HasOnlyWhiteSpaceContent())
         {
             base.RenderContents(writer, context);
         }
         else
         {
             writer.WriteText(Text);
         }
     }
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:14,代码来源:RouteLink.cs


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