Is there any problem with mixing WriteBeginTag and RenderBeginTag in the same code?

1.4k views Asked by At

I am generating XHTML for a non-standard browser (Polycom Microbrowser). I would like to use the XhtmlTextWriter, but it ignores the border attribute on table. This is mostly like the correct thing to do since you should be using CSS to set the border. Alas, Polycom doesn't support CSS.

So when I Render the beginning and ending table tags, I need to use HtmlTextWriter.WriteBeginTag/WriteEndTag instead of HtmlTextWriter.RenderBeginTag/RenderEndTag.

    protected void RenderTableBegin(HtmlTextWriter writer)
    {
        //writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
        //writer.RenderBeginTag(HtmlTextWriterTag.Table);
        writer.WriteBeginTag("table");
        writer.WriteAttribute("border", "0");
        writer.Write(HtmlTextWriter.TagRightChar);
    }

    protected void RenderTableEnd(HtmlTextWriter writer)
    {
        writer.WriteEndTag("table");
        //writer.RenderEndTag();
    }

Other places in my code, I am using HtmlTextWriter.RenderBeginTag/RenderEngTag. Are there any known issues with mixing these? Am I OK as long as I used matching calls?

1

There are 1 answers

0
Brian Mains On BEST ANSWER

I don't believe so that there is an issue, but there is a difference in the way it renders tags. If you want control over the process, you could just render the entire HTML yourself in a writer.Write statement too.

writer.Write("<table border=\"0\">");

Just to ensure the final output if you are having issues with that. I know the big difference is the way that the rendering process happens (for render begin tag, attributes have to be added before, whereas writebegintag adds attributes after as you have).

HTH.