title: Adding custom attributes to asp.NET RadioButton control
body: <p>I want to add a custom attribute to an asp.net RadioButton called <code>Key</code> which I'm using client-side for an ajax request.</p>
  
  <p>What I'm finding is that my aspx markup which is the following:</p>
  
  <pre><code>&lt;asp:RadioButton ID="rdoPost" GroupName=PreferredContactMethod" value="Post" onclick="DoStuff(this)" runat="server" /&gt;
  </code></pre>
  
  <p>gets rendered in the page as</p>
  
  <pre><code>&lt;span Key="ContactMethod"&gt;
     &lt;input id="rdoPost" type="radio" name="PreferredContactMethod"" value="Post" onclick="DoStuff(this);" /&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>whereas I'd expected (and hoped) to get the following</p>
  
  <pre><code>&lt;input id="rdoPost" type="radio" Key="ContactMethod" name="PreferredContactMethod"" value="Post" onclick="DoStuff(this);" /&gt;
  </code></pre>
  
  <p>I've tried the same thing with an asp TextBox control and it works exactly as I'd expect simply adding the <code>Key="myKey"</code> attribute to the <code>&lt;input type="text"/&gt;</code> element.</p>
  
  <p>Is there a way around this with the standard RadioButton control, or will I have to inherit from the standard one to achieve the markup I'm wanting?</p>
  
  <p>Also... (sorry to ask two questions at the same time), is adding non-standard attributes to html markup a bad idea anyway? Currently I'm using these attributes in JavaScript in the following way:</p>
  
  <pre><code>var key = rdoPost.Key;
  </code></pre>