Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>create a Filter (class that inherits from <code>Stream</code>), assign it to your <code>HttpContext.Response.Filter</code> attribute, and in it you would overwrite the <code>Write</code> method, to remove all the name-tags from the generated html :)</p> <p>See this page for more information <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx">http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx</a></p> <p><strong>Update</strong></p> <p>Looking at the sourcecode for <code>TextBox</code> it reveals that Name is actually added to the <code>Attributes</code>-list during render, so it should be possible to interfere with the rendering of the <code>TextBox</code> class and prevent this attribute from being added. This should do</p> <pre><code>public class NoNamesTextBox : TextBox { private class NoNamesHtmlTextWriter : HtmlTextWriter { public NoNamesHtmlTextWriter(TextWriter writer) : base(writer) {} public override void WriteAttribute(string name, string value, bool fEncode) { if (name.Equals("name", StringComparison.OrdinalIgnoreCase)) return; base.WriteAttribute(name, value, fEncode); } } protected override void Render(HtmlTextWriter writer) { var noNamesWriter = new NoNamesHtmlTextWriter(writer); base.Render(noNamesWriter); } } </code></pre> <p><strong>Update once more</strong></p> <p>How could i forget! You don't even need to subclass your textbox. In asp.net you can define which HtmlTextWriter type you want to use per control, so you can just configure that every TextBox control should use an instance of your own NoNamesHtmlTextWriter like this</p> <pre><code>&lt;browsers&gt; &lt;browser refID="Default"&gt; &lt;controlAdapters&gt; &lt;adapter controlType="System.Web.UI.WebControls.TextBox" adapterType="NoNamesTextBoxAdapter" /&gt; &lt;/controlAdapters&gt; &lt;/browser&gt; &lt;/browsers&gt; public class NoNamesTextBoxAdapter : ControlAdapter { private class NoNamesHtmlTextWriter : HtmlTextWriter { public NoNamesHtmlTextWriter(TextWriter writer) : base(writer) { } public override void WriteAttribute(string name, string value, bool fEncode) { if (name.Equals("name", StringComparison.OrdinalIgnoreCase)) return; base.WriteAttribute(name, value, fEncode); } } protected override void Render(HtmlTextWriter writer) { var noNamesRender = new HtmlTextWriter(writer); base.Render(noNamesRender); } } </code></pre>
 

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