Reputation: 693
I am an ASP.Net MVC noob.
I cannot get checkboxes to render correctly i.e. checked/unchecked.
This is a snippet of my view:
<input id="<%= item.ReportName + "|" + "email" %>" type="checkbox" checked="<% if (item.Email == true) { %>true<% } else { %>false<% } %>" onclick="ajaxfunction(this)" />
This is the source view from IE:
<input id="TestRep02|showinhomelist" type="checkbox" onclick="ajaxfunction(this)" />
Notice that there is no checked attribute in the html source.
Any ideas?
Upvotes: 1
Views: 860
Reputation: 602
it should be:
<input id="<%= item.ReportName + "|" + "email" %>"
type="checkbox" <% if (item.Email == true) { %>checked="yes"<% } %>"
onclick="ajaxfunction(this)" />
Note: The checked attributes accepts "yes" and "no".. not true or false..
Upvotes: 1