locked
rendered control with HtmlTextWriterTag.B RRS feed

  • Question

  • User-14247900 posted

    hi,

    when i try to render the control like that:

                        output.Write("<br/>");
                        output.RenderBeginTag(HtmlTextWriterTag.Font);
                        output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "150px");
                        output.AddStyleAttribute(HtmlTextWriterStyle.Color, "green");
                        output.RenderBeginTag(HtmlTextWriterTag.B);
                        output.Write(Text);
                        output.RenderEndTag();
                        output.RenderEndTag();
    i get what i was expected to see.
    But, when i take out the <b/> element as in:
                        output.Write("<br/>");
                        output.RenderBeginTag(HtmlTextWriterTag.Font);
                        output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "150px");
                        output.AddStyleAttribute(HtmlTextWriterStyle.Color, "green");
                        //output.RenderBeginTag(HtmlTextWriterTag.B);
                        output.Write(Text);
                        output.RenderEndTag();
                        //output.RenderEndTag();
    the result rendered page take the style and wrap it the hidden field instead of the control (as it does when the <b/> is available.
    I know it's a simple one.
    But why is this difference in behavior? what if all i want is the same result but with no bold text?
     
    Friday, November 18, 2011 11:04 AM

Answers

  • User3866881 posted

    Hello:)

    RenderBeginTag——this is the starter of a container HTML element, and the mapping one is the RenderEndTag().

    But——if you comment it out, it will directly output the plain text without a container that hold it.

    Best reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 19, 2011 8:46 PM