Note that there are some explanatory texts on larger screens.

plurals
  1. PORender Self-Closing Tag in ASP.NET custom control derived from Control
    text
    copied!<p>I'm working on a Facebook FBML controls library and would like to create my FBML controls somewhat patterned like the ASP.NET WebControls library. I have a base class that handles rendering by default; here's my render method:</p> <pre><code> protected override void Render(HtmlTextWriter writer) { AddAttributesToRender(writer); if (UseXfbmlSemantics) { writer.RenderBeginTag(ElementName); writer.EndRender(); writer.RenderEndTag(); } else { writer.RenderBeginTag(ElementName); writer.RenderEndTag(); } } </code></pre> <p>What I would like is for the rendering to be modified based on UseXfbmlSemantics - if it's true, it should render, for instance:</p> <pre><code>&lt;fb:name uid="10300399458"&gt;&lt;/fb:name&gt;</code></pre> <p>When it's false, it should render with a self-closing tag:</p> <pre><code>&lt;fb:name uid="10300399458" /&gt;</code></pre> <p>I can get the "true" condition to work almost correctly, but the self-closing tag seems to be incompatible with the Render- set of methods. Unfortunately if that's the case it also means that the AddAttributesToRender pattern wouldn't work, either. What it's actually producing is this:</p> <pre><code> &lt;fb:name uid="10300399458"&gt; &lt;/fb:name&gt; </code></pre> <p>How can I get HtmlTextWriter (or which HtmlTextWriter do I need to use) to make it render a self-closing tag? Or, at the very least, how can I make it not render that interim space (so that the opening and closing tags are immediately next to one another)?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload