title: Asp.net server side Conditional attribute or unchecked attribute?
body: <p>I have the following aspx code:</p>
  
  <pre><code>  &lt;% foreach (ModelDefect modelDefect in GetCodes())
    {%&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;input disabled="disabled" name="&lt;%= modelDefect.Code %&gt;" value="&lt;%= modelDefect.Code %&gt;" type="checkbox" checked="&lt;%=modelDefect.CompletedDate.HasValue? "checked":string.Empty %&gt;" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href="javascript:submitForm('&lt;%= modelDefect.DefectId %&gt;');"&gt;&lt;%= modelDefect.Code %&gt;&lt;/a&gt;&lt;/td&gt;   
      &lt;td&gt;&lt;%= modelDefect.Description %&gt;&lt;/td&gt;&lt;td&gt;&lt;%= modelDefect.AddedDate %&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>I want the check box to be checked if there is a completed date, and unchecked if not. <a href="http://www.w3schools.com/TAGS/att_input_checked.asp" rel="nofollow noreferrer">W3</a> doesn't appear to say how to leave it unchecked but include the attribute. I don't see a way to conditionally include that attribute on the item. I found a page that suggests that checked="yes" or checked="no" should work but it hasn't. I'd like a browser-independent and standards based solution or... a clean way to conditionally add that tag server side on my asp that is Ajax friendly? (Response.Write doesn't work in Asp.net AJax as I understand it.)</p>