Just having the checked
attribute on the input
is enough to make it checked. In HTML, you just need to have checked
in there, in XHTML, it should be checked="checked"
, but either way, you'll want to exclude the whole attribute if it isn't checked.
That is, GetIsChecked
should (be renamed and) return either "checked='checked'"
or String.Empty
. You will then call it just in the input tag itself, not as the value for the checked
attribute (which you should remove). It'll look something like this:
<input name="phoneRadio" class="phoneRadio" id="rbDefaultPhone" type="radio" <%# GetChecked(Eval("IsDefault"))%> />
protected string GetChecked(object isDefault)
{
return (bool)isDefault ? "checked='checked'" : string.Empty;
}